请问怎么用jquery改变文字

请问怎么用jquery改变文字


蛊毒传说
浏览 422回答 3
3回答

万千封印

<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()函数最为合适

扬帆大鱼

...<script type="text/javascript">$().ready(function(){$("#myLabel").hover(function(){$(this).html("已改");},function(){$(this).html("未改");});});</script>...<label id="myLabel">未改</label>...&nbsp;

蓝山帝景

$("#div").bind("mouseenter",function(){$(this).html("被修改了");}).bind("mouseleave",function(){$(this).html("原来文字");});之所以不用hover或者mouseover,纯属个人经验,用mouseenter不管是浮动还是绝对、相对定位、z-index都没有影响,前者则不行&nbsp;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery