As previously stated classes would be better. Also of note, @ in attribute
selectors is deprecated, but better yet, input:checkbox (which is faster
than simply :checkbox I've been told). Also, if you insist on doing ids
instead of class, it'd be better to use the "starts
with<http://docs.jquery.com/Selectors/attributeStartsWith#attributevalue>"
method than .each and a substr.

On Tue, Jun 30, 2009 at 09:38, evanbu...@gmail.com <evanbu...@gmail.com>wrote:

>
> I want to check all of my checkboxes in my form that have an id that
> begins with 'chkEvent'.  Thanks
>
> <script language="Javascript" type="text/javascript">
> $(document).ready(function() {
>   $("#toggleEvents").click(function(event){
>      $('inp...@type=checkbox]').each( function() {
>
>        // Begin this is where I am lost
>        if($(this).id()=='chkEvent*')
>        // End this where I am lost
>        this.checked = !this.checked;
>      });
>   });
> });
> </script>
>
>
> <a href="#" id="toggleEvents">Toggle Events</a>
>
> <form method="post" action="">
> <input type="checkbox" value="EventAcceleratedOptionVesting"
> id="chkEventAcceleratedOptionVesting" />
> <input type="checkbox" value="AccountingChanges"
> id="chkEventAccountingChanges" />
> <input type="checkbox" value="AnnualMeetingChanged"
> id="chkEventAnnualMeetingChanged" />
> <input type="checkbox" value="AssetSalePurchase"
> id="chkEventAssetSalePurchase" />
> <input type="checkbox" value="AuditorChange"
> id="chkEventAuditorChange" />
> </form>

Reply via email to