方法:1、利用“.class”选择器给指定的一行元素设置样式;2、给按钮绑定点击事件并指定处理函数;3、在函数中利用removeClass()方法去除指定行元素的类即可去除一行样式,语法为“元素对象.removeClass("指定类")”。

本教程操作环境:windows10系统、jquery3.2.1版本、Dell G3电脑。
jquery怎样点击按钮去掉一行样式
可以利用.class选择器给指定的元素设置样式。
这样就可以一次性去除元素的样式,使用css方法也能够去除样式,但是不能直接全部去除,因此使用了removeClass方法。
removeClass() 方法从被选元素移除一个或多个类。
示例如下:
<meta><title>123</title><script>
</script><script>
$(document).ready(function(){
$("button").click(function(){
$("p").removeClass("intro");
});
});
</script><style>
.intro{
font-size:120%;
color:red;
}
</style><h1>这是一个标题</h1>
<p>这是一行段落。</p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/gongju/2331" title="jQuery 1.12.4"><img
src="https://img.php.cn/upload/manual/001/431/639/6a21619eac924328.png" alt="jQuery 1.12.4" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/gongju/2331" title="jQuery 1.12.4" class="overflowclass">jQuery 1.12.4</a>
<p class="overflowclass">jQuery 1.12.4是jQuery 1.x系列的最后一个正式稳定版本,由jQuery团队于2016年发布。该版本主要面向需要兼容旧版浏览器环境的网站和Web应用,尤其适用于仍需支持Internet Explorer 6、Internet Explorer 7、Internet Explorer 8等老旧浏览器的项目。</p>
</div>
<a rel="nofollow" href="/xiazai/gongju/2331" title="jQuery 1.12.4" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>
<p>这是另一行段落。</p>
<button>移除指定一行的样式</button>
输出结果:

点击按钮后:

相关视频教程推荐:jQuery视频教程










