3 回答

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊
<script type="text/javascript">
$().ready(function(){
$("#myLabel").hover(function(){
$(this).text("已改");
},
function(){
$(this).text("未改");
});
});
</script>
...
<label id="myLabel">未改</label>
最好是把html函數(shù)改用text(),html是替換指定元素內(nèi)的所有內(nèi)容,而text()只會(huì)替換文字,假如你的myLabel中還設(shè)置有<span style='color:red'>Content</span>,那么使用text()函數(shù)最為合適

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
<script type="text/javascript">
$().ready(function(){
$("#myLabel").hover(function(){
$(this).html("已改");
},
function(){
$(this).html("未改");
});
});
</script>
...
<label id="myLabel">未改</label>
...

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
$("#div").bind("mouseenter",function(){
$(this).html("被修改了");
}).bind("mouseleave",function(){
$(this).html("原來(lái)文字");
});
之所以不用hover或者mouseover,純屬個(gè)人經(jīng)驗(yàn),用mouseenter不管是浮動(dòng)還是絕對(duì)、相對(duì)定位、z-index都沒(méi)有影響,前者則不行
- 3 回答
- 0 關(guān)注
- 325 瀏覽
添加回答
舉報(bào)