I have this code http://jsfiddle.net/s2CtY/16/ which works perfectly. However what l need is for
我有这个代码http://jsfiddle.net/s2CtY/16/完美的工作。然而,我需要的是
1.The click to show the DIV plus open an external link 2. To allow multiples of this via PHP
1.单击以显示DIV并打开外部链接2.通过PHP允许多次此操作
Can anyone help ?
有人可以帮忙吗?
$(document).ready(function () {
$('.sub-nav ul').css("display","none");
// Watch for clicks on the "slide" link.
$('.sub-nav-btn').click(function () {
$(this).next(".sub-nav ul").slideToggle(400);
$(this).slideToggle(400);
return false;
});
$('.sub-nav').on('click', 'ul', function () {
$(this).prev(".sub-nav-btn").slideToggle(400);
$(this).slideToggle(400);
return false;
});
});
HTML
<div class="sub-nav">
<div class="sub-nav-btn"><a href="http://www.yahoo.com">btn1</a></div>
<ul>btn1 slide data
</ul>
</div>
<div class="sub-nav">
<div class="sub-nav-btn">btn2</div>
<ul>btn2 data slide
</ul>
</div>
1 个解决方案
#1
1
You should be able to accomplish this using window.open();
Capture the links URL into a var and pass that var to window.open()
like so:
你应该能够使用window.open();将链接URL捕获到var中,并将该var传递给window.open(),如下所示:
$(document).ready(function () {
$('.sub-nav ul').css("display","none");
// Watch for clicks on the "slide" link.
$('.sub-nav-btn').click(function () {
var url = $(this).children('a').attr('href');
if(url != null){
window.open(url);
}
$(this).next(".sub-nav ul").slideToggle(400);
$(this).slideToggle(400);
return false;
});
$('.sub-nav').on('click', 'ul', function () {
$(this).prev(".sub-nav-btn").slideToggle(400);
$(this).slideToggle(400);
return false;
});
});
DEMO Hope this helps!
DEMO希望这有帮助!
#1
1
You should be able to accomplish this using window.open();
Capture the links URL into a var and pass that var to window.open()
like so:
你应该能够使用window.open();将链接URL捕获到var中,并将该var传递给window.open(),如下所示:
$(document).ready(function () {
$('.sub-nav ul').css("display","none");
// Watch for clicks on the "slide" link.
$('.sub-nav-btn').click(function () {
var url = $(this).children('a').attr('href');
if(url != null){
window.open(url);
}
$(this).next(".sub-nav ul").slideToggle(400);
$(this).slideToggle(400);
return false;
});
$('.sub-nav').on('click', 'ul', function () {
$(this).prev(".sub-nav-btn").slideToggle(400);
$(this).slideToggle(400);
return false;
});
});
DEMO Hope this helps!
DEMO希望这有帮助!