Reputation: 59
Neither of the alert box works for following code -
var genvalue=('input[#gender]:checked').val());
alert (genvalue);
var value = $("#edu_det1").val();
alert (value);
But when genvalue, the whole portion of code is remove it work. Don't know what the problem
Upvotes: 1
Views: 138
Reputation: 441
This is correct code and you have missed $
var genvalue=$('input[#gender]:checked').val());
alert (genvalue);
var value = $("#edu_det1").val();
alert (value);
If you are applying something else then it might not work properly. The correction as per your code is that much only but if you need more correction still getting wrong you need to give some more code snippets.
Well try this to get more information and learn about jquery value selection method
Upvotes: 1
Reputation: 318252
If you are trying to get an element with an ID, just target that ID as it should be unique :
var genvalue = $('#gender').val();
alert (genvalue);
var value = $("#edu_det1").val();
alert (value);
Otherwise you can also do :
var genvalue = $('input[id="gender"]:checked').val();
But that sort of defeats the point of having an ID !
Upvotes: 2
Reputation: 15861
you are missing $. (jquery object). try to include your jquery library. or else you can use Jquery CDN
var genvalue=('input[#gender]:checked').val());// here $ is missing
use the CDN
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'>
Upvotes: 3