I have a table with multiple rows and columns populated by php and mySQL. For some of the td\'s I\'m adding jQuery click-events in the document.ready function to let the use
You want to use live events, which were introduced in 1.3.
$("tr.clickable").live("click", function() {
//add input fields
});
$("span#addNewRow").live("click", function() {
$("table").append(' ... ')
});
UPDATE: Note that as of jQuery 1.7, live()
is deprecated. Use on()
instead. And in some cases, delegate()
may be a better choice. See the comments below.
Example of how to use .on():
$("table").on("click", "tr.clickable", function() {
//add input fields
});