点击它后如何突出显示html页面中的按钮? [英] How to highlight a button in html page when i click on it?

查看:191
本文介绍了点击它后如何突出显示html页面中的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>


推荐答案

检查这个 JSFiddle

基本上,你点击一个highligt效果与jQuery按钮,当点击它喜欢这个

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 );
});

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

NOTE: As said in the comments, 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

这篇关于点击它后如何突出显示html页面中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆