user1555446
user1555446

Reputation: 21

how to select a radio button by clicking on an option and not the actual button itself

say i have the following three options and each with a radio button beside

I need jQuery that when the user clicks on the word the radio button selects!

Upvotes: 2

Views: 64

Answers (4)

Remy
Remy

Reputation: 12703

You can use the label tag:

<input id="emptyacct" type="radio" name="account" value="radiobutton" />
<label for="emptyacct">Yes </label>

Upvotes: 1

thecodeparadox
thecodeparadox

Reputation: 87073

Two ways:

  1. <label for="london"><input type="radio" id="london"> London</label>.

Use label's for attribute similar to radio's id.

  1. <label><input type="radio" > London</label>

Place the radio within label.

Very basic HTML.

Upvotes: 1

David Hellsing
David Hellsing

Reputation: 108500

This is a built-in feature in HTML, so no need for JavaScript. Simply use the label tag like this:

<label><input type="radio"> London</label>
<label><input type="radio"> New York</label>
<label><input type="radio"> Dubai</label>

Upvotes: 1

kbdjockey
kbdjockey

Reputation: 897

It's just HTML ;)

<input id="input_london" type="radio" name="london" value="radiobutton" />
<label for="input_london">London</label>

<input id="input_ny" type="radio" name="ny" value="radiobutton" />
<label for="input_ny">New York</label>

...

Upvotes: 0

Related Questions