How would you do something like this:
somemethod($("#buttonelement"));
function(ele) {
ele.click(function(event) { alert("hi"); });
}
in other words how do you pass in an element as a jquery object and register the click event.
How would you do something like this:
somemethod($("#buttonelement"));
function(ele) {
ele.click(function(event) { alert("hi"); });
}
in other words how do you pass in an element as a jquery object and register the click event.
Just like that...?
function someMethod(ele) {
ele.click(function(event) {
alert("hi");
});
}
someMethod($("#buttonelement"));
The jQuery object is just like any other object in Javascript and can be passed to functions as normal.