Cla*_*are 2 jquery jquery-selectors
嘿那里,有一些问题在jQuery中传递参数值.我需要一个div来打开一个作为Shadowbox对话框打开的链接..(Shadowbox使用rel标签)因此我需要获得href和rel的值,但不能弄明白.我试图将.attr("rel")添加到字符串但是没有用.
我的jquery:
$("div.banner").click(function() {
window.location = $(this).find("a").attr("href"); return false; });
Run Code Online (Sandbox Code Playgroud)
谢谢!
我不完全确定你在追求什么,但如果你想在构建window.location字符串时同时使用rel和href属性,你需要做这样的事情.
$("div.banner").click(function() {
var $link = $(this).find("a");
window.location = $link.attr("href") + $link.attr("rel");
return false;
});
Run Code Online (Sandbox Code Playgroud)