使用Jquery 怎样修改内部DIV层的title属性值?

使用Jquery 怎样修改内部DIV层的title属性值


紫衣仙女
浏览 4110回答 3
3回答

慕田峪9158850

HTML:<a href="#"&nbsp;id="change">change</a><div&nbsp;id="58972" class="d" tag="dirs"> <div class="name" title="555">777</div> </div>JQ:<script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(document).ready(function(){$("#change").click(function(){$(".name").attr("title","111");});});</script>希望能帮到你,如果有用,请采纳,谢谢!$(".name:first").attr("title","111"); 第一个$(".name:first").attr("title","111"); 最后一个HTML<a href="#"&nbsp;id="change">change</a><div id="58972" class="d" tag="dirs"> <div class="name" title="555">777</div> </div><div id="1111" class="d" tag="dirs"> <div class="name" title="555">777</div> </div

天涯尽头无女友

例:<div title="标题">aa</div>title改为我的标题四个字。方法:$("div").attr("title","我的标题");//jquery中的属性attr应用如下:attr(name|properties|key,value|fn)概述设置或返回被选元素的属性值。

慕婉清6462132

如果你单单修改这一个div,必须要有指定的 ID 或唯一的 class 来定位 divclass="d" 应该不可用,因为其它 div 可能也有 d 这个 class你的 tag="dirs" 中的 tag 不是合法属性,如果是&nbsp;HTML5,可以使用 data-tag="dirs"所以要修改 title 值,你最好能提供一下上下文(div id="58972" 的 父层)
打开App,查看更多内容
随时随地看视频慕课网APP