conditional loop in jquery selector -


how can select first 3 div elements in following example using jquery?

i want select div elements status = 0 until encounter other value.

<div status='0'></div> <div status='0'></div> <div status='0'></div> <div status='1'></div> <div status='0'></div> 

the following example need first 2 elements

<div status='0'></div> <div status='0'></div> <div status='1'></div> <div status='1'></div> <div status='0'></div> 

var divs = []; $('div[status]').each(function() {     if ($(this).attr('status') === '0') {         divs.push(this);     } else {         return false;     } }); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -