3 回答

TA贡献1797条经验 获得超6个赞
<script type="text/javascript">
$().ready(function(){
$("#myLabel").hover(function(){
$(this).text("已改");
},
function(){
$(this).text("未改");
});
});
</script>
...
<label id="myLabel">未改</label>
最好是把html函数改用text(),html是替换指定元素内的所有内容,而text()只会替换文字,假如你的myLabel中还设置有<span style='color:red'>Content</span>,那么使用text()函数最为合适

TA贡献1865条经验 获得超7个赞
<script type="text/javascript">
$().ready(function(){
$("#myLabel").hover(function(){
$(this).html("已改");
},
function(){
$(this).html("未改");
});
});
</script>
...
<label id="myLabel">未改</label>
...

TA贡献1828条经验 获得超3个赞
$("#div").bind("mouseenter",function(){
$(this).html("被修改了");
}).bind("mouseleave",function(){
$(this).html("原来文字");
});
之所以不用hover或者mouseover,纯属个人经验,用mouseenter不管是浮动还是绝对、相对定位、z-index都没有影响,前者则不行
- 3 回答
- 0 关注
- 300 浏览
添加回答
举报