3

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

这些按钮用于将数据传递给控制器​​。他们是这样的:

<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>
4

1 回答 1

4

检查这个JSFiddle

基本上,当像这样单击它时,您使用 jQuery 将高亮效果绑定到按钮

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

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

于 2013-07-19T13:22:11.450 回答