gpt4 book ai didi

javascript - JQuery 在页面加载时更改 value = myValue 的按钮类

转载 作者:行者123 更新时间:2023-11-28 20:21:53 25 4
gpt4 key购买 nike

这是我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com