How do I add target=“_blank” to a link within a specified div?

前端 未结 7 1627
失恋的感觉
失恋的感觉 2020-11-27 03:29

Let\'s say I have the following code:


      
7条回答
  •  执念已碎
    2020-11-27 03:29

    Use this for every external link

    $('a[href^="http://"], a[href^="https://"]').attr('target', '_blank');
    

提交回复
热议问题