-1

Here is my html:

            <div   id="12hrs">12hrs</div>
            <div   id="24hrs">24hrs</div>
            <div   id ="none">None</div>

I assigned id i need to know which id to be selected?

Kuppuraj
  • 389
  • 1
  • 6
  • 26
  • 2
    why didn't you use input radio tag... 12 hrs – Sukrit Gupta Jul 29 '15 at 08:20
  • In addition to above, Also use `name` attribute to group them then you can use `var value = $('input.radio_btn:checked').val();` – Satpal Jul 29 '15 at 08:21
  • possible duplicate of [How can I know which radio button is selected via jQuery?](http://stackoverflow.com/questions/596351/how-can-i-know-which-radio-button-is-selected-via-jquery) – Pindo Jul 29 '15 at 08:21
  • You need to give more info, like which lib you use to create a radio from the `
    `.
    – fuyushimoya Jul 29 '15 at 08:22
  • http://jsfiddle.net/arunpjohny/73hu8udv/1/ – Arun P Johny Jul 29 '15 at 08:24
  • Is there any reason your radio button isn't an actual radio button? Ideally you should always write semantic markup and follow best practice. Trying to replicate an input element typically causes more problems that it solves. – James Jul 29 '15 at 08:24
  • It is generally considered necessary to at least attempt to solve a problem before it is posted on SO. Please show us what you tried. – Burki Aug 20 '15 at 07:38

1 Answers1

1

Assign class something like this

<div class='temp'  id="12hrs">12hrs</div>
<div class='temp'  id="24hrs">24hrs</div>
<div class='temp' id ="none">None</div>

then

$(".temp").on('click',function(){
        $(".temp").removeClass('active');
        $(this).addClass('active');
    });
Kuppuraj
  • 389
  • 1
  • 6
  • 26