这是我的 HTML 代码
<input type="button" class="green red" value="Open"/>
<input type="button" class="red yellow" value="Close"/>
<input type="button" class="orange red" value="Close"/>
<input type="button" class="blue red black" value="Close"/>
我想在加载页面时使用 JQuery 更改按钮的样式类。
要求:对于具有值“关闭”的按钮,样式类红色应替换为绿色。
注意:我无法更改上面的代码,因为它是自动生成的。
您能否告诉我如何在使用 JQuery/Java 脚本加载页面时更改样式
最佳答案
尝试
jQuery(function($){
$('input.red:button[value="Close"]').removeClass('red').addClass('green')
})
关于javascript - JQuery 在页面加载时更改 value = myValue 的按钮类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18149050/