我的JS代码,在文本框中输入.为什么点击按钮,不能在对话框输出
<!DOCTYPEHTML><html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb...
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
.name1{
color:#C00;}
.name2{
color:#30F;}
.name3{
background:#03C}
.name4{
font-size:20px;}
.name5{
font-family:"华文行楷";}
.name6{
font-weight:bold;}
.name7{
font-style:italic;}
.name8{
text-decoration:line-through;}
.name9{
text-decoration:overline;}
.name10{
text-decoration:underline;}
.name11{
text-align:left
;}
.name12{
}
</style>
</head>
<body>
<script type="text/javascript">
function my(){
var mima=document.getElementsByName("mimi")
alert(mima);
}
</script>
<table table width="400" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="69" height="32" class="name1">名称</th>
<th width="69" class="name2">规格</th>
<th width="69" class="name3">价格</th>
<th width="69" class="name4">销量</th>
</tr>
<tr>
<th class="name5">武器</th>
<th class="name6">人气</th>
<th class="name7">稳稳</th>
<th class="name8" id="text1" ><input type="password" name="mimi"></th>
</tr>
<tr>
<th height="32" class="name9">恶趣</th>
<th class="name10">后跳</th>
<th class="name11">舒服</th>
<th class="name12"><button type="submit" onClick="my()" style="background-color:#09F;">点击</button></th>
</tr>
</table>
<form>
</form>
</body>
</html>
求大神看看哪里需要修改
我就是想在文本框随便输入密码.然后按按钮,然后对话框会输出我输入的密码. 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
.name1{
color:#C00;}
.name2{
color:#30F;}
.name3{
background:#03C}
.name4{
font-size:20px;}
.name5{
font-family:"华文行楷";}
.name6{
font-weight:bold;}
.name7{
font-style:italic;}
.name8{
text-decoration:line-through;}
.name9{
text-decoration:overline;}
.name10{
text-decoration:underline;}
.name11{
text-align:left
;}
.name12{
}
</style>
</head>
<body>
<script type="text/javascript">
function my(){
var mima=document.getElementsByName("mimi")
alert(mima);
}
</script>
<table table width="400" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="69" height="32" class="name1">名称</th>
<th width="69" class="name2">规格</th>
<th width="69" class="name3">价格</th>
<th width="69" class="name4">销量</th>
</tr>
<tr>
<th class="name5">武器</th>
<th class="name6">人气</th>
<th class="name7">稳稳</th>
<th class="name8" id="text1" ><input type="password" name="mimi"></th>
</tr>
<tr>
<th height="32" class="name9">恶趣</th>
<th class="name10">后跳</th>
<th class="name11">舒服</th>
<th class="name12"><button type="submit" onClick="my()" style="background-color:#09F;">点击</button></th>
</tr>
</table>
<form>
</form>
</body>
</html>
求大神看看哪里需要修改
我就是想在文本框随便输入密码.然后按按钮,然后对话框会输出我输入的密码. 展开
2个回答
2017-08-05
展开全部
document.getElementsByName("mimi")[0].value;
你应该要获取name是mimi的单个元素的值,而不是集合
你应该要获取name是mimi的单个元素的值,而不是集合
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询