jquery - select link, automatically checks the checkbox to the left of it -


i want user able hover on link, click it, , automatically check checkbox left of it, , when select it, uncheck box.

how do this?

<input type="checkbox" name="favorite_color" value="orange"> <a href="#" rel="favorite_color">orange</a>

instead of link (anchor), use <label> designed this:

<input type="checkbox" name="favorite_color" id="favorite_color" value="orange">  <label for="favorite_color">orange</label> 

or without id, wrapped around it:

<label><input type="checkbox" name="favorite_color" value="orange"> orange</label> 

with both of these there's no javascript required, built-in browser behavior.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -