admin管理员组文章数量:1332388
I have four buttons on the page, when I click on one of them i want it to be highlighted.
The buttons are used to pass data to a controller. They are like this:
<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>
I have four buttons on the page, when I click on one of them i want it to be highlighted.
The buttons are used to pass data to a controller. They are like this:
<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>
Share
edited Jul 11, 2017 at 22:15
J. Lavoie
3343 gold badges5 silver badges24 bronze badges
asked Jul 19, 2013 at 13:17
user2595861user2595861
831 gold badge2 silver badges9 bronze badges
8
- 4 You can't have two elements with the same id! – bfavaretto Commented Jul 19, 2013 at 13:18
- 2 buttons have redirect code. wouldn't they redirect after click? – user1 Commented Jul 19, 2013 at 13:19
- yes that is a problem i am facing, because of redirect option its loading the basic settings – user2595861 Commented Jul 19, 2013 at 13:21
- is there any reason not to use normal links? – bitWorking Commented Jul 19, 2013 at 13:21
- and i changed the id's :) – user2595861 Commented Jul 19, 2013 at 13:21
1 Answer
Reset to default 4check this JSFiddle
basically, you bind a highligt effect to the button with jQuery, when clicking it like this
$('button').click(function() {
$(this).effect( "highlight", {color: 'red'}, 3000 );
});
NOTE: As said in the ments, you should never have 2 elements with the same id on one page. If you want to use the same descriptor, use class
instead of id
本文标签: javascriptHow to highlight a button in html page when i click on itStack Overflow
版权声明:本文标题:javascript - How to highlight a button in html page when i click on it? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742290394a2447686.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论