[jQuery] Re: Large clickable boxes

2007-09-06 Thread Klaus Hartl
jason wrote: Klaus, Why not simply: $(function(){ $('li.deal').click(function(){ location.href = $('h2 a', this).attr('href'); }); }); Ha! I thought I'd need to disable the contained anchor element (thus I captured the href in a closure), but that's probably

[jQuery] Re: Large clickable boxes

2007-09-05 Thread jason
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

[jQuery] Re: Large clickable boxes

2007-09-05 Thread Frantisek Malina
Cool, works like a charm in 5.5 upwards, Opera, FF. I spent few hours with this and you did it in a minute or so. On Sep 5, 5:40 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote: > Klaus Hartl wrote: > > $(function() { > > $('li.deal').each(function() { > > var $a = $('h2 a', this); > >

[jQuery] Re: Large clickable boxes

2007-09-05 Thread Klaus Hartl
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...:

[jQuery] Re: Large clickable boxes

2007-09-05 Thread Klaus Hartl
Frantisek Malina wrote: Hi all, I need large clickable boxes which span the whole area of the ".deal" box. Href attribute should be extracted from links wrapped in heading2. I tried loads of experimants and ended up with the following disfunctional code. It should work, but it simply doesn't. A

[jQuery] Re: Large clickable boxes

2007-09-05 Thread Franck Marcia
A classic one : embed your code like this: $(function() { // your code here }); Otherwise, li.deal doesn't exist yet when your code runs. Franck. On 5 sep, 18:11, Frantisek Malina <[EMAIL PROTECTED]> wrote: > Hi all, > I need large clickable boxes which span the whole area of the ".deal" >