for example
var variable = "plus"; $('#id').click(function(){ $(this).html('текст'+variable+'текст'); }) for example
var variable = "plus"; $('#id').click(function(){ $(this).html('текст'+variable+'текст'); }) There was such a trouble. Solved the problem by concatenating a variable before inserting it into $ .html ()
What's the problem? Despite the fact that onclick is an event, and it will work after the external code, the variable variable will be available inside the handler.
This useful JavaScript feature is called closure .
I'm not sure that I was able to solve your evil and brilliant idea, but it seems to me that in your case it would be possible to get out using the live function that successfully binds the handler to all newly created elements.
Source: https://ru.stackoverflow.com/questions/68897/
All Articles
html()"? - LeD4eG