简体   繁体   中英

Add target=“_blank” to the anchor tags

How do I add target="_default" to the anchor tag in this code below? I want to open all of the link in new window

function() {  
     $('.status_success>a').each(function(i,e){ 
    var eVal = $(e).text(); 
    if (eVal == "Success"){ 
       e.click(); 
    } 
 }); }

Thank you j08691 for the code. I realized that what I need is blank, not default to open all the links in new tab.

Here is the fixed code:

function () {
$('.status_success>a').each(function (i, e) {
    var eVal = $(e).text();
    $("*").attr('target', '_blank');
    if (eVal == "Success") {
        e.click();
    }
});

}

Add $(this).attr('target', '_default') :

function () {
    $('.status_success>a').each(function (i, e) {
        var eVal = $(e).text();
        $(this).attr('target', '_default');
        if (eVal == "Success") {
            e.click();
        }
    });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM