gpt4 book ai didi

javascript - 当我点击它时如何突出显示html页面中的按钮?

转载 作者:可可西里 更新时间:2023-11-01 01:03:13 26 4
gpt4 key购买 nike

我在页面上有四个按钮,当我点击其中一个按钮时,我希望它突出显示。

按钮用于将数据传递给 Controller ​​。他们是这样的:

<button name="region" id="region" type="button"  onclick="window.location='/project/Viewdata/index/region/1'" class="current">ALL</button>
<button name="region" id="region2" type="button" onclick="window.location='/project/Viewdata/index/region/2'" class="current">1st</button>

最佳答案

检查这个JSFiddle

基本上,当您像这样单击按钮时,您可以使用 jQuery 将高光效果绑定(bind)到该按钮

$('button').click(function() {
$(this).effect( "highlight", {color: 'red'}, 3000 );
});

注意:如评论中所述,您永远不应在一页上有 2 个具有相同 ID 的元素。如果要使用相同的描述符,请使用 class 而不是 id

关于javascript - 当我点击它时如何突出显示html页面中的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17747112/

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