Edward,

That's oh I forgot that. Anyways, the .each syntax was what I really
wanted. Thanks a bunch.



On 9 Jan, 20:30, Peter Edwards <p...@bjorsq.net> wrote:
> You could use the title attribute rather than your non-standard txt
> attribute, and achieve the same thing using:
>
> <script type="text/javascript">
> $(document).ready(function(){
>      $("#tryme").click( function(){
>          var checkedGenres = [];
>          $("input[rel='genre']:checked").each(function(){
>              checkedGenres.push($(this).getAttribute('title'));
>          });
>          alert( checkedGenres.join(", ") );
>          $("#divGenres").text(checkedGenres.join(", "));
>      });});
>
> </script>
>
> on 09/01/2010 13:57 swfobject_fan said::
>
>
>
> > Hi,
>
> > I'm using this piece of code to find a set of selected check boxes
> > that are selected abd build a comma separated list from their values
> > ('txt' custom attribute). Is this a jQuery standard method?
>
> > e.g
> > <input type="checkbox" id="chkGenre" rel="genre" value="12"
> > txt="Rock" /> <br />
> > <input type="checkbox" id="chkGenre rel="genre" value="13" txt="Jazz" /
>
> > <script type="text/javascript">
> > $(document).ready(function(){
>
> >    $("#tryme").click( function(){
> >            var oChecked = $("input[rel='genre']:checked");
> >            var checkedGenres = new Array;
> >            for( var i=0; i<oChecked.length; i++ ) {
> >                    checkedGenres[i] = oChecked[i].getAttribute('txt');
> >            }
>
> >            alert( checkedGenres.join(", ") );
> >            $("#divGenres").text(checkedGenres.join(", "));
> >    });
>
> > });
> > </script>

Reply via email to