dom manipulation - remove 3 last divs with jQuery -



dom manipulation - remove 3 last divs with jQuery -

<div id="widgetareafooter"> <div class="row">1</div> <div class="row">2</div> <div class="row">3</div> <div class="row">4</div> <div class="row">5</div> <div class="row">6</div> <div class="row">7</div> </div>

how remove 3 lastly div ?

i tryed doesn't work :/

var row = $( '#widgetareafooter>.row' ); var nbr = row.length ; ( var i=4;i<nbr;i++ ) row.get(i).remove(); or ( var i=4;i<nbr;i++ ) row[i].remove();

this remove lastly 3 elements:

$('#widgetareafooter > .row').slice(-3).remove();

jsfiddle demo

you can part of jquery collection using .slice().

if negative number provided, indicates position starting end of set, rather beginning.

jquery dom-manipulation dom-traversal

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -