I have a loop which generates lot of input text fields with jquery. Now i want to fire stopPropagation method when someone clicks on those input tags. I am in a notion that this method works like this:
event.stopPropagation()
But problem is that i want to fire this method on onClick attribute of the input tag. Like this:
$(handler).html('<input type="text" value="'+text+'" style="width:280px;" onClick=stopPropagation(); />');
And this won’t work for obvious reasons. I need to get the event object for this click. Whats the smarter way?
Its easy, just add “event” key word to your onClick call, like so:
Then in your function:
or you can do it the jQuery way:
keep in mind, on your inline functions, just like the word
this,eventis a key word that tells the js your function should be getting an event argumentFinally you could just change the add all together: