Why $(":select").focus does not work while $(":input").focus works?
- by user605660
Hi. I have a JQuery code which does something when input or select elements get focus.
Although my code for input element works, select element does not work.
Here is what I do.
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(":input").focus(function () { //this works
//do something
});
$(":select").focus(function () { //this doesn't
//do something
});
});
</script>
</body>
I tried some variation on select, such as using $("select") instead of $(":select"),
but did not work either.
I am a beginner for JQuery.
I appreciate if you could tell me how I can make it work.
Thanks a lot!