jQuery: MouseOver Event Binding and Input Value Retrieval
February 5th, 2009 by jeremychoneGrabbing an input value from a HTML list on mouseover:
<ul id="toyList"> <li>Car <input id="toyId" value="123" /></li> <li>Snowplow <input id="toyId" value="432" /> </li> <li>Carcarrier <input id="toyId" value="234" /> </li> </ul>
<script type="text/javascript">
$(document).ready(function() {
$("#toyList li").bind("mouseover",function(e){
alert("over element: " + $(this).children("input['toyId']").attr("value"));
});
});
</script>
See also:
jQuery Bind (use jQuery Live if the list change dynamically)