使用jQuery的特定于目标的href
我用这个代码在一个页面上打开多个链接, 但— 1.我希望代码只针对具有类链接的div中的href-- 2.我将需要在另一个页面上重复使用相同的代码,但目标是所有带有类链接的链接使用jQuery的特定于目标的href,jquery,click,href,Jquery,Click,Href,我用这个代码在一个页面上打开多个链接, 但— 1.我希望代码只针对具有类链接的div中的href-- 2.我将需要在另一个页面上重复使用相同的代码,但目标是所有带有类链接的链接 <a href="#!mylink" class="links">Link</a> 感谢您的帮助。您可以: $("div a.links[href]"); 你可以做: $("div a.links[href]"); 你可以试试 $('#ButtonOne').click(function(
<a href="#!mylink" class="links">Link</a>
感谢您的帮助。您可以:
$("div a.links[href]");
你可以做:
$("div a.links[href]");
你可以试试
$('#ButtonOne').click(function() {
$('div a.links').each(function() {
window.open($(this).attr('href'););
});
});
你可以试试
$('#ButtonOne').click(function() {
$('div a.links').each(function() {
window.open($(this).attr('href'););
});
});
您可以尝试使用jQuery的方法 像这样的东西应该有用
if($('div').hasClass('links')){
// do what you need to with the links in here
}
您可以尝试使用jQuery的方法 像这样的东西应该有用
if($('div').hasClass('links')){
// do what you need to with the links in here
}
非常感谢。这个看起来很不错,谢谢。这个看起来很漂亮。