I have written some jQuery code, this is a part of it. this always return UNDEFINED. why is that
<html>
<head>
<script src="theme/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#my").click(function() {
alert($("#adults").val());
});
});
</script>
</head>
<body>
<form>
<a href="#" id="my">click</a>
<select class="text" id="currency" id="adults">
<option value="1" selected="selected">1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
</select>
</form>
</body>
</html>
This is used to get how many adults are there. Can’t run without it.
You can’t use id attribute two times on one node (in fact id values should be unique across one html page). In your case use either currency or adults.
If you get rid of extra
id="currency"jQuery will return correct value using expression$("#adults").val().