Find whether a particular cell of a table has an img tag
- by SilentPro
I am generating a table dynamically using Django.
The same table template is used to generate a variety of tables depending on the data supplied. In one scenario a particular column contains image tags.
Since my table is editable (using jquery) the image cell also becomes editable and removes my content.
I want some special behavior on double click of such cells like say upload an image. How do I accomplish this with a jquery?
My script for making the table editable is given below.
$(function() {
$("td").dblclick(function() {
var OriginalContent = $(this).text();
$(this).addClass("cellEditing");
$(this).html("<input type='text' value='" + OriginalContent + "' />");
$(this).children().first().focus();
$(this).children().first().keypress(function(e) {
if (e.which == 13) {
var newContent = $(this).val();
$(this).parent().text(newContent);
$(this).parent().removeClass("cellEditing");
}
});
$(this).children().first().blur(function() {
$(this).parent().text(OriginalContent);
$(this).parent().removeClass("cellEditing");
});
});
});