$(this).attr('title')

-- 
http://ranacseruet.blogspot.com/

On Mon, Jan 11, 2010 at 11:58 AM, swfobject_fan <guru4v...@gmail.com> wrote:

> Peter,
>
> The $(this).getAttribute didn't work for me in any browser.
>
> I changed it to this:
> checkedGenres.push(this.getAttribute('title'));
>
> But is this a standard method? Safer?
>
> -guru
>
> 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