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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -