Reputation: 33
I have an overlay in which i have placed one .jsp file which has one textbox. Find below the content of .jsp file:
<input id="sample" size="15" type="text">
Now i want to fire a keyup event on this textbox using below jQuery function:
jQuery(function() {
alert("hi 1");
//will perform some other tasks//
jQuery("sample").keyup(function() {
alert("hi 2");
});
});
Note: Nothing is coming up.
Upvotes: 0
Views: 149
Reputation: 15961
The problem here is that you're not calling jQuery right. The selectors in jQuery are similar to CSS - #yourId
and .yourClassName
You'll need:
jQuery("#sample").keyup(
function() {
alert("hi 2");
}
);
Upvotes: 0
Reputation: 630469
You need a #
in an #id
selector (otherwise it's an element selector, looking for a <sample>
element), like this:
jQuery("#sample").keyup(function() {
alert("hi 2");
});
Upvotes: 1