Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery selecting a forms radio buttons

I have a form and I use this document.forms["form-0"].answerN[0]; to select a specific radio button, however I could not manage to do it with jQuery.

I tried $('forms["form-0"]') and $('forms[0]') to get to the form but it didn't work, and both do work using the long path..

like image 717
ilyo Avatar asked May 24 '11 10:05

ilyo


2 Answers

you can access like this ( jQuery v1.6)

$('form > input:radio').prop('id');

DEMO

update

As you can aceess form by name or id attribute also like this

 $('form[name="firstForm"] > input:radio').prop('id');

DEMO

like image 178
diEcho Avatar answered Nov 08 '22 07:11

diEcho


Try like this: $("form input:radio")

For further assistance follow this link.

like image 37
intellidiot Avatar answered Nov 08 '22 07:11

intellidiot