vendredi 2 janvier 2015

How to get the value of checkbox in Jquery


I have a HTML element:

<a style='text-decoration:none;' id='$innerdata[0]' class='cat' href='#'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='vehicle' value='Bike'>&nbsp;$innerdata[1]</a>


I am trying to get the value of checkbox.



$('body').on('click', '.cat', function()
{
$topcat = $(this);
alert ($topcat.closest().find('[type=checkbox]').val());


}


But alert is printing undefined.


How to get the value of checkbox ??





Aucun commentaire:

Enregistrer un commentaire