Jquery get selected checkboxes

Posted by kevin on Stack Overflow See other posts from Stack Overflow or by kevin
Published on 2010-04-26T11:14:51Z Indexed on 2010/04/26 11:23 UTC
Read the original article Hit count: 581

Filed under:
|

Hi id like to get the list of selected checkboxes ina page, actually what I really need is th get the text of the element next to the checkbox which is a html element

  • the code is below and its not working the html is as follows

        <script type="text/javascript">
    
            $(document).ready(function () {
                $('#target').click(function () {
                    alert("in");
                    var checkValues = [];
                     $('input[name=checkboxlist]:checked').each(function() {
                alert($(this)val());
               checkValues.push($(this)val());
              });
            });
    
        });
        </script>
    
    HTML:
    
        <ul id="7b1fe2bd-1b26-4185-8cd9-aec10e652a70">
         <li>Structured Products<input type="checkbox" name="checkboxlist"</li>
         <li>Global FID
         <ul>
          <li>PowerPoint Presentations<input type="checkbox" name="checkboxlist"</li>
          <li>Global Deck
          <ul>
           <li>Test1<input type="checkbox" name="checkboxlist"</li>
    
           <li>Test2<input type="checkbox" name="checkboxlist"</li>
           <li>Test3<input type="checkbox" name="checkboxlist"</li>
    
          </ul>
          <input type="checkbox" name="checkboxlist"</li>
          <li>Credit Default Swaps Position
          <ul>
           <li>Test4<input type="checkbox" name="checkboxlist"</li>
    
           <li>Test5<input type="checkbox" name="checkboxlist"</li>
    
          </ul>
          <input type="checkbox" name="checkboxlist"</li>
          <li>Thought Leadership<input type="checkbox" name="checkboxlist"</li>
          <li>Fixed Income Perspectives<input type="checkbox" name="checkboxlist"</li>
          <li>Public Policy Information and Regulatory<input type="checkbox" name="checkboxlist"</li>
    
          <li>Regional FID<input type="checkbox" name="checkboxlist"</li>
    
         </ul>
         <input type="checkbox" name="checkboxlist"</li>
         <li>Global Rates<input type="checkbox" name="checkboxlist"</li>
         <li>Global Credit Products<input type="checkbox" name="checkboxlist"</li>
         <li>FX<input type="checkbox" name="checkboxlist"</li>
    
         <li>Emerging Markets<input type="checkbox" name="checkboxlist"</li>
         <li>Commodities<input type="checkbox" name="checkboxlist"</li>
         <li>testcat<input type="checkbox" name="checkboxlist"</li>
         <li>testcat<input type="checkbox" name="checkboxlist"</li>
    
        </ul>
    
  • © Stack Overflow or respective owner

    Related posts about jQuery

    Related posts about JavaScript