Hello everybody It is my first post here I guess. I must say - I love jQuery, thank you ! A few days ago I faced a problem that I cannot overcome and hope you can help me. In the group archive I saw similar problem, but solved in the way I have it solved, which is not sufficient for me right now.
I have a menu, which contains links within <li> elements. I want JS to "click" on the real link whenever user clicks on the li element, but can't do that due to propagation. As one said there is a solution - catch attr("href") and use window.location.href ... that's workaround I used until now. But what if your link has target defined, causing new page to be opened in new window? That's the problem I faced and window.location.href is no longer correct solution here. At this moment, in case o QV Report (below), instead of clicking on the <li> "button" user have to click on the link. This would open new page or new tab depends on browser configuration. If I remove e.stopPropagation() from onclick event then click causes infinite loop. Here is my HTML code, simplified <ol id="menu_ma" > <li ><a href="index.php" class="menulink">Home</a></li> <li ><a href="assets.php" class="menulink" >Assets</a></li> <li ><a class='menulink' href='aaaaa.php' target='_blank'>QV Report</ a></li> </ol> and js code $("#menu_ma a") .click(function(e){ $(this) .closest("li.ui-selectee").addClass("ui- selected") .siblings().removeClass("ui-selected"); e.stopPropagation(); }) $("#menu_ma li") .hover( function(){ $(this).addClass("ui-state-highlight cursor-pointer"); }, function(){ $(this).removeClass("ui-state-highlight cursor-pointer"); }) .click(function(e){ link=$(this).find("a").attr("href"); if(link!=undefined){ var me = $(this); var target = me.find("a").attr("target"); if( me.find("a").attr("target")!= "_blank") window.location.href=link; else{ me.find("a").trigger("click"); } } }) As you see when <li> is clicked I trigger the click on <a> ... but this propagates again on <li> causing loop. I stopped the propagation but then "click" doeasn't work. I don't know how to solve this, but believe that there must be a solution or maybe different approach. If you have any ideas I will appreciate your comments. Best regards Norbert