Find whether a particular cell of a table has an img tag
Posted
by
SilentPro
on Stack Overflow
See other posts from Stack Overflow
or by SilentPro
Published on 2013-06-27T22:18:29Z
Indexed on
2013/06/27
22:21 UTC
Read the original article
Hit count: 205
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");
});
});
});
© Stack Overflow or respective owner