javascript - jQuery on click event function to be used as a normal function as well -
javascript - jQuery on click event function to be used as a normal function as well -
i have event handler method executes on click of button. pass on info shown below
$( "button" ).on( "click", {name: "hello"}, greet );    and method defined as:
function greet(event) {     //  utilize   info event.data.name     // access dom element on click method invoked $(this) }    but want utilize function normal js function.
how pass on info({name: "namaskara"})? how set context -  illustration have button <button id="kannada" /> , want  utilize button context , sent greet() function $(this) used in function button      
1). reply first question.
but want utilize function normal js function. how pass on info {name: "namaskara"}?":
you need pass in object data property:
greet({data: {name: "namaskara"}});    2). sec question context:
var $kannada = $('#kannada'); // button greet.call($kannada[0], {data: {name: "namaskara"}});    in case greet invoked if manually clicked #kannada button, meaning context this pointing button#kannada. of  course of study in case event object  within greet not real mouse event, have data property set.
 javascript jquery 
 
  
Comments
Post a Comment