Find equal row in table and add span before another

Hello guys.
Need some help to find “QteOfOutPackSpan” span in equal row in “AddFieldsToPreviewDiv” and add
another span before that if some conditions.
Jsfiddle

So far I 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>');
        };

    });

Hi,

I’m not sure if it helps, but you can get even table rows thus: $( "tr:even" ).

Other than that, would you mind explaining a little about what you are trying to accomplish and I’m sure we’ll find a solution.

Found a solution:

$('#AddFieldsToPreviewDiv tr:gt(0)').each(function () {
var $PackSpan = $(this).find("span[name='QteOfOutPackSpan']");
if ($PackSpan.text().length > 0) {
$PackSpan.before("<psan> i </span>");
};
});

Working jsfiddle.

That’s good to know.
Thanks for taking the time to report back.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.