Reputation: 63
i have dynamically created no-of rows and no-of columns based on the requirement using for loops.
for (i = 0; i < a ; i++) {
$("table").append("<tr id='tr" + i + "'></tr>");
for (j = 0; j < b ; j++) {
$('[id^="tr' + i + '"]').append("<td><input type='text' class='add1' id='textbox" + i + "" + j + "'/></td>");
}
}
i have tried using blur event along with live like below
$(document).live("input.add1", "blur", function (event) {
});
i have to print addition after each row and column. please help
with regards
Ramu
Upvotes: 0
Views: 36
Reputation: 11
use Delegate instead of live
$(document).delegate("input.add1", "blur", function (event) {
});
because delegate ..The .delegate() method behaves in a similar fashion to the .live() method, but instead of attaching the selector/event information to the document, you can choose where it is anchored. Just like the .live() method, this technique uses event delegation to work correctly.
Example :if you write function for ROW Addition then you can have code like below
$('[id=""]').each(function () {
Addition($(this).val());
});
Similarly you can use same Addition function for COLUMN addition.
All the best
Upvotes: 1
Reputation: 50563
.live()
is deprecated, use the new .on()
method as is the prefered way to do event delegation as you want to do, like this:
$(document).on("blur", "input.add1", function (event) {
//your code
});
Upvotes: 0