Hien Le
Hien Le

Reputation: 47

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();
    }
});

}

Upvotes: 0

Views: 2357

Answers (1)

j08691
j08691

Reputation: 208012

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();
        }
    });
}

Upvotes: 4

Related Questions