jquery - Find equal row in table and add span before another -
i have 2 tables, "addfieldstoformdiv" , "addfieldstopreviewdiv" , need find "qteofoutpackspan" span in "addfieldstopreviewdiv" table (and add span beforet that) if 2 inputs in "addfieldstoformdiv" filled.
so far have this:
$("input[name='volym1']").each(function (index) { var $qteofouterpack = $(this); var $outerpacktype = $(this).closest("tr").find("input[name='volym2']"); var $previewtable = $("#addfieldstopreviewdiv"); var $row = $previewtable.find('tr:eq(' + index + ')'); var $packspan = $row.find("span[name='qteofoutpackspan']"); if ($qteofouterpack.val().length > 0 && $outerpacktype.val().length > 0) { $packspan.before('<span>som text</span>'); } else {alert('do else'); } });
and jsfiddle play.
found solution:
$('#addfieldstopreviewdiv tr:gt(0)').each(function () { var $packspan = $(this).find("span[name='qteofoutpackspan']"); if ($packspan.text().length > 0) { $packspan.before("<psan> </span>"); }; });
working jsfiddle.
Comments
Post a Comment