My "JQuery Selector Foo" stinks. I need to find all HREF's with a target attr of _blank and replace them with a common window/target. Assistance is greatly appreciated!
In jQuery, the class and ID selectors are the same as in CSS. If you want to select elements with a certain class, use a dot ( . ) and the class name. If you want to select elements with a certain ID, use the hash symbol ( # ) and the ID name.
jQuery selectors allow you to select and manipulate HTML element(s). jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
Description. _blank. Opens the linked document in a new window or tab. _self. Opens the linked document in the same frame as it was clicked (this is default)
Conclusion. You can use the target="_blank" attribute if you want your users to click on a link that opens up a new browser tab. The target="_blank" attribute is used inside the opening anchor tag like this.
try
$("a[target=_blank]").each(function () {
var href = $(this).attr("href"); // retrive href foreach a
$(this).attr("href", "something_you_want"); // replace href attribute with wich u want
// etc
});
let me know what do you want, for more help
$("a[target='_blank']").attr('target', 'sometarget');
Do you mean something like that?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With