Помогите, пожалуйста, составить запрос на jQuery
Есть примерно такая html-конструкция (конструкция упрощена. В оригинале всё сложнее)
<div id="smartList> <div class="smartListItem" idMessage="28"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="15"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="8"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="43"> <input type="checkbox"/> </div> </div> Нужно при помощи jQuery (либо другим способом) получить массив значений idMessage только тех div-ов, внутри которых чекбоксы отмечены. :help: Сломал себе мозг. Не пойму как вытащить атрибуты внешних элементов в зависимости от внутренних. :-? |
Цитата:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <style type="text/css"> </style> <script type="text/javascript"> function Go() { var o,str='',d='' o=$('#smartList :checkbox[checked="true"]').parent().each(function (){ str+=d+$(this).attr('idMessage') d=', ' }) alert(str) } </script> </head> <body> <div id="smartList"> <div class="smartListItem" idMessage="28"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="15"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="8"> <input type="checkbox"/> </div> <div class="smartListItem" idMessage="43"> <input type="checkbox"/> </div> </div> <input type='button' value='Go' onclick='Go()' /> </script> </body> </html> |
Спасибо. На основе данного примера разобрался и сделал то что нужно было):thanks:
|
Часовой пояс GMT +3, время: 05:03. |