user2595861
user2595861

Reputation: 83

How to highlight a button in html page when i click on it?

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>

Upvotes: 3

Views: 14691

Answers (1)

Jamie De Palmenaer
Jamie De Palmenaer

Reputation: 864

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

Upvotes: 4

Related Questions