onmouseover,onmouseout不工作?

时间:2017-05-28 12:18:21

标签: javascript

<body>
  

脚本无效

<script>

function show(inp,spanId){


var msg=document.getElementById(spanId);

msg.innerHTML="<font color="red" size="6">",inp.id;

}

function hide(spanId){
var msg=document.getElementById(spanId);
msg.innerHTML="";
}
</script>
  

功能无法正常工作

<input type='text' id='name' onmouseover="show(this,namemessage)" onmouseout="hide(namemessage)" />

<span id='namemessage'></span>
<br/>
<input type='text' id='email' onmouseover="show(this,emailmessage)" />

<span id='emailmessage'></span>



<body>

&#13;
&#13;
function show(inp, spanId) {


  var msg = document.getElementById(spanId);
  msg.innerHTML = '<font color="red" size="6">'+inp.id+'</font>';

}

function hide(spanId) {
  var msg = document.getElementById(spanId);
  msg.innerHTML = "";
}
&#13;
<input type='text' id='name' onmouseover="show(this,'namemessage')" onmouseout="hide('namemessage')" />

<span id='namemessage'></span>
<br/>
<input type='text' id='email' onmouseover="show(this,'emailmessage')" />

<span id='emailmessage'></span>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我不知道你想用这段代码做什么,但你的代码中有很多错误。 检查下面的代码没有错误

<input type='text' id='name' onmouseover="return show(this,'namemessage')" onmouseout="return hide('namemessage')" />

<span id='namemessage'></span>
<br/>
<input type='text' id='email' onmouseover="return show(this,'emailmessage')" />

<span id='emailmessage'></span>
<script>

function show(inp,spanId){
var msg=document.getElementById(spanId);
msg.innerHTML='<font color="red" size="6">'+inp.id+'</font>';
}

function hide(spanId){
var msg=document.getElementById(spanId);
msg.innerHTML="";
}
</script>