请问这样用对吗
$("#voice>div").each(function(i){this.onmouseover="this.innerHTML='<embed src='bird.mp3' style='display:none' loop='1' autostart=true>'+'<img src='song.gif' name='bird.mp3' width='16' height='16'/>'+this.innerHTML";
});
程序代码:html:
<div id="test">
<div>first</div>
<div>second</div>
</div>
js:
<script>
$(function(){
$('#test >div').mouseover(function(){
alert(this.innerHTML);
this.innerHTML="<embed src='bird.mp3' style='display:none' loop='1' autostart=true>"
+"<img src='song.gif' name='bird.mp3' width='16' height='16'/>"
+this.innerHTML;
alert(this.innerHTML);
});
// "this.innerHTML='<embed src='bird.mp3' style='display:none' loop='1' autostart=true>'+'<img src='song.gif' name='bird.mp3' width='16' height='16'/>'+this.innerHTML";
});
</script>