I have two tables and I want to have change event on one table. That is whe开发者_运维百科n I click on first table, I want to have some changes to the second table. But somehow below change function is not working. Any suggestions?
$("#history_table table:eq(0)").click(function(){
$("#history_table table:eq(1) thead tr th:nth-child(1)").html("New");
});
$("#history_table table:eq(1) thead tr th:nth-child(1)").change(function() {
alert('Handler for .change() called.');
});
Here history_table is a div tag id and it has two tables. click() function is working but I am expecting to see alert message as well, but this is not showing.
The .change()
event/handler isn't for (or fired by default for) this, it's for an input style element changing data, for example a <input>
or a <select>
. Instead, you'll want a custom event (or manually firing change
...) here, for example:
$("#history_table table:eq(0)").click(function(){
$("#history_table table:eq(1) thead tr th:nth-child(1)").html("New")
.trigger('myEvent');
});
$("#history_table table:eq(1) thead tr th:nth-child(1)").bind('myEvent', function() {
alert('Handler for .change() called.');
});
精彩评论