i wish to get the li value when the button beside it is clicked. if the button beside apple is clicked i should get apple on an alert box. i,ve been stuck on this for a day now. any help is appreciated.
<ul>
<li>apple<input type="button" value="show">.
<li>jam<input type="button" value="show">.
<ul>
jquery
$("input[type=button]").click(function()
{
alert( $(this).parent().text());
});
you should close the
litags:Edit: the script works without closing the li’s, sounds that jQuery is not loaded correctly.
http://jsfiddle.net/D9Jv7/1/