我搜索了 stackoverflow,但没有找到任何答案。
请检查下面的html
<button type="button" class="nacnchor" value="1">hello</button>
<button type="button" class="nacnchor" value="2">hello</button>
<button type="button" class="nacnchor" value="3">hello</button>
我可以根据类更改按钮的文本
$('button.nacnchor').text("REWRITE");
但我想根据属性值更改值,是否有类似 $('button.nacnchor,attr(value=1)')
:p 的东西。
最佳答案
属性选择器记录在此处:http://api.jquery.com/attribute-equals-selector/
$("button.nacnchor[value='1']").text("REWRITE");
关于javascript - 根据属性更改按钮的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19541542/