Reputation: 10095
I would like to set the html to "" after a key has been pressed (once). This is my code so far:
$(document).one("keypress","td",function(){
$(this).html("");
});
However, it only works with one table row. Is there away I can apply this to all my table (which is loaded dynamically) rows?
<table class="table">
<tr>
<td contenteditable="True">Some text</td>
</tr>
<tr>
<td contenteditable="True">Some text</td>
</tr>
</table>
Upvotes: 0
Views: 30
Reputation: 95066
I would switch to .on and just make the td no longer match the selector after it has been clicked once.
$(document).on("keypress","td:not(.cleared)",function(){
$(this).empty()/*.html("")*/.addClass("cleared");
});
Upvotes: 1