Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Radio Button Clickable Link

Tags:

html

css

I have a link that holds a radio button, which I want to make a clickable link. I've tried:

<a href="/">
  <input type="radio" style="pointer-events:none;">
</a>

This prevents anything from happening when I click the radio button. I would like it to follow the link. Any ideas?

http://css-tricks.com/almanac/properties/p/pointer-events/

like image 904
Dan Baker Avatar asked Mar 21 '14 20:03

Dan Baker


People also ask

How do you select a radio button when clicking text?

To select a radio button by clicking on its text in React:Add a label element for each radio button. The htmlFor prop of each label should be set to the id of each radio button. Click on the label element to select the radio button.

How do you make a radio button editable?

You will need to set the ReadOnly property of txt1 to false in the CheckedChanged event handler for rad1 , and set it to true for the CheckedChanged event handler for all the other radio buttons. void Foo() { txt1. ReadOnly = true; // this makes the text box read-only (uneditable) txt1.


2 Answers

You can use JavaScript to turn elements like that into a link. E.g.:

<input type="radio" onclick="window.location='/';" />

If other elements should be combined on the link with the radio button, put the onclick attribute on the wrapping element.

like image 168
tvkanters Avatar answered Sep 28 '22 10:09

tvkanters


Instead of an <a> tag, try surrounding the radio button with a <div> with an onClick event:

<div onClick="window.location = 'http://google.com/';">
    <input type="radio" style="pointer-events:none;"> 
</div>
like image 45
Lil' Bits Avatar answered Sep 28 '22 12:09

Lil' Bits