jquery add row on click only if it's empty?
Posted
by KittyYoung
on Stack Overflow
See other posts from Stack Overflow
or by KittyYoung
Published on 2010-04-20T03:56:51Z
Indexed on
2010/04/20
4:03 UTC
Read the original article
Hit count: 275
The code below works, insomuch that if I click in an input field, it'll add another row. I'm trying to figure out though, how to do that only if the input field is empty?
$("#tableSearchData > tbody > tr > td > input").bind('focus', function(){
var row = $(this).closest("tr").get(0);
if( row.className.indexOf("clicked")==-1 )
{
var rowCopy=$(row).clone(true);
$(row).closest("tbody").append(rowCopy);
row.className+=" clicked";
}
});
© Stack Overflow or respective owner