2012-11-12 48 views
1
<table > 
     <tr> 
      <td>[email protected]</td> 
      <td> 
       <select name="limit"> 
        <option selected="selected">Can Edit</option> 
        <option>Can View</option> 
       </select> 
      </td> 
      <td> 
       <i class="icon-remove"></i> 
      </td> 
     </tr> 
     <tr> 
      <td>[email protected]</td> 
      <td> 
       <select name="limit"> 
        <option>Can Edit</option> 
        <option selected="selected">Can View</option> 
       </select> 
      </td> 
      <td> 
       <i class="icon-remove"></i> 
      </td> 
     </tr> 
    </table> 

考慮上面的HTML,如何獲得所有使用jQuery選擇Can Edit選項的電子郵件?非常感謝。jQuery:如何獲取所有選中Can Edit選項的電子郵件?

回答

3
var emails = []; 

$('option:selected').each(function() 
{ 
    if ($(this).html() == 'Can Edit') 
    emails.push($(this).closest('tr').find('td:first').html()); 
}); 
+0

'.parent( )'應該''.parents()' – Ohgodwhy

+0

@Ohgodwhy同意。更新我的代碼 –

+0

也應該是'選項:選中' –

相關問題