开发者

need to get rel attribute and href attribute when making a while div clickable in jquery

开发者 https://www.devze.com 2022-12-16 22:32 出处:网络
Hey there, having some issues passing parameter values in jQuery. I need a div to open a link that opens as a Shadowbox dialog .. (Shadowbox uses the rel tag) i therefor开发者_如何学Goe need to get th

Hey there, having some issues passing parameter values in jQuery. I need a div to open a link that opens as a Shadowbox dialog .. (Shadowbox uses the rel tag) i therefor开发者_如何学Goe need to get the value of both the href and rel, but cant' figure it out. i tried to just add .attr("rel") to the string but that didnt work.

My jquery:

$("div.banner").click(function() {  
     window.location = $(this).find("a").attr("href"); return false;     }); 

thank you!


I'm not entirely sure what you're after, but if you wanted to use both the rel and href attributes when building the window.location string, you'd need to do something like this.

$("div.banner").click(function() {
    var $link = $(this).find("a");
    window.location = $link.attr("href") + $link.attr("rel");
    return false;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号