Skip to content Skip to sidebar Skip to footer

How To Combine Tags As Long As They Have The Same Class

The Html that I'm getting ideally looks like this: See the more detailed areas of what not Next my aim is to change the span tag into

Solution 1:

There is the + selector which selects consecutive elements: http://jsfiddle.net/NWWYC/1/.

$(".RapidLink1-H + .RapidLink1-H").each(function() {
    // move contents to previous span, remove this span afterwards
    $(this).prev(".RapidLink1-H").append(
        $(this).contents()
    ).end().remove();
});

Post a Comment for "How To Combine Tags As Long As They Have The Same Class"