Thursday, June 20, 2013

Storing a function with jQuery to a html element and call it


var myElm = $(".some-element-class");

myElm[0].someFunction = function() {
    console.log("here");
}

if(myElm[0].someFunction !== undefined && myElm[0].someFunction != null 
    && typeof myElm[0].someFunction == "function") {
    myElm[0].someFunction(param1, param2);
}

No comments:

Post a Comment