Klaus,

Why not simply:

$(function(){
        $('li.deal').click(function(){
                location.href = $('h2 a', this).attr('href');
        });
});


Is it better to use .each()? Doesn't seem to be required. Same
with .bind('click') vs. .click()...?

Thanks for your insights,
Jason




On Sep 5, 12:40 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Klaus Hartl wrote:
> > $(function() {
> >     $('li.deal').each(function() {
> >         var $a = $('h2 a', this);
> >         $(this).bind('click', function(e) {
> >             if (e.target != $a[0]) {
> >                 location.href = $a.attr('href');
> >             }
> >         });
> >     });
> > });
>
> shorter, shorter...:
>
> $(function() {
>      $('li.deal').each(function() {
>          var a = $('h2 a', this)[0];
>          $(this).bind('click', function(e) {
>              if (e.target != a) {
>                  location.href = a.href;
>              }
>          });
>      });
>
> });
>
> (in this case we don't really need any normalization via attr('href'))
>
> --Klaus

Reply via email to