So, I have this & lt; Ol & gt;
with some events related to jQuery help (1.4.2). All is done in $ (document) .ready ()
-call
The strange thing is that & lt; Li & gt; Click
Correnct & lt; A & gt; Generates a click on
(I can see it by canceling console.log ()
-part) but it does not navigate to UA. Why is it like this? event.stopPropagation ()
call event.preventDefault ()
internal or what?
I know I can do window.location.href
But I really want to know why it is not working with click-call. & lt; Li & gt; Click
in the event = $ ('H3A', this) .eq (0) .attr ('href');
Thanks with the advance companion!
Teh Codez:
HTML:
& lt; Ol class = "news" & gt; & Lt; Li & gt; & Lt; Img src = "http://dummyimage.com/325x325/000/fff.jpg" & gt; & Lt; Span class = "date" & gt; May 12 & lt; / Span & gt; & Lt; H3 & gt; & Lt; A href = "http://example.com/lorem-ipsum" & gt; Laurem Epsom & lt; / A & gt; & Lt; / H3 & gt; & Lt; P & gt; Noolam Rockas, Massa Enk Pointer Retrm, Maurice Mets Honor Lockes, Societies. Rhoncus purus or lectus & Lt; / P & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Span class = "date" & gt; May 3 & lt; / Span & gt; & Lt; H3 & gt; & Lt; A href = "http://example.com/lam-sum-idum" & gt; Lam amount ID & lt; / A & gt; & Lt; / H3 & gt; & Lt; P & gt; Maurice Wollepat Anem Hell Troupe Firtrators Cross Fossibus Metis Dignissim. & Lt; / P & gt; & Lt; / Li & gt; & Lt ;! - Here are many more details ... - & gt; & Lt; / Ol & gt;
(And yes, HTML 4.01 is valid.)
Javascript:
$ ('.news li') .click (Function () {$ ('h3 a', this) .eq (0) .click ();}) hover (function () {$ (this) .toggleClass ('hover');}) ('H3A') (function (e) {e.stopPropagation (); // stop recursion; //console.log (this);});
This is normal, a click
is manually Firing anchors follow the not link, firing the "default event" is often not the case when the action was followed
$ ('. Click (function () {window.location .href = $ (this) .find ('h3aa'). Attr ('href');}). Hover (function () {$ (this) .toggleClass ('hover');}). ('H3 a'). Click (function (e) {e.stopPropagation (); // therefore works on ctrl + click link, etc});
On the one hand, there is no need for .eq (0)
, .attr ('href')
Href
from the first element in the matched set.
Comments
Post a Comment