Reputation: 1068
$(document).ready(function(){
$("a").click(function() {
$("#content").load($(this).attr("href"));
window.location.hash = $(this).attr("href");
return false;
});
});
So I use this code to make all links load in the div (content). But I want all links that have a target of _blank (new page), to open up in a new page - as their default behaviour. How can I do this?
Cheers in advance - (I'm a jQuery noob :) )
Upvotes: 1
Views: 80
Reputation: 29976
I think this should do it:
$(document).ready(function(){
$("a[target!='_blank']").click(function(){
$("#content").load($(this).attr("href");
window.location.hash=$(this).attr("href");
return false;
});
});
Replaced:
$("a").click(function(){...}
With:
$("a[target!='_blank']").click(function(){...}
http://docs.jquery.com/Selectors/attributeNotEqual#attributevalue
Upvotes: 4