简体   繁体   English

使用Jquery从弹出窗口中打开新选项卡中的链接

[英]Open link in new tab from pop-up using Jquery

I am trying to open up a new page using a link in a pop-up in a new tab. 我正在尝试使用新标签页弹出窗口中的链接打开一个新页面。 I am new to Jquery so I am unsure if this is on the correct track: 我是Jquery的新手,所以不确定这是否正确:

 $('.modal-content a').click(function() {
      alert( "Handler for .click() called." );
      a.set('target', '_blank');
    });

HTML: HTML:

<div class="modal-content">
    <div>
        <h1>This is  pop-up</h1>
    </div>
<p><a href="www.google.co.nz">Open in new window</a></p>
</div>

"modal-content" is the class name of the pop-up div. “ modal-content”是弹出div的类名称。 I am not sure if I am calling the link element correctly. 我不确定我是否正确调用了link元素。 There is no unique identifier on the tag. 标签上没有唯一的标识符。

Any help will greatly be appreciated. 任何帮助将不胜感激。

.attr() .attr()

$('a').attr('target', '_blank');

or .prop() .prop()

$('a').prop('target', '_blank');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果单击一个链接 - 打开一个弹出窗口,但是如果有人在新选项卡中单击它,则应打开一个新选项卡 - if a link is clicked - open a pop-up, but if somebody clicked it with open in new tab, a new tab should open 如何在弹出窗口中打开一个新标签? - How to open up a new tab in a pop-up? 打开新选项卡时,检查弹出窗口阻止程序是否有问题 - Check if pop-up blocker is enbled when open new tab onscroll()打开一个新选项卡,而没有弹出警报 - onscroll() to open a new tab without pop-up alert JavaScript / jQuery - 在弹出窗口中打开当前链接 window - JavaScript / jQuery - Open current link in pop-up window 如何从现有的弹出窗口中打开一个新的弹出窗口? - How to open a new pop-up from an existed pop-up? 弹出新标签页的首次访问? - New tab pop-up first visit? 使用jQuery单击时,Textarea打开一个弹出窗口 - Textarea open a pop-up when click using jQuery 选中(始终在新选项卡中打开弹出窗口)时,如何强制弹出窗口在新窗口中打开? - How to force a pop-up to open in a new window while (Always open pop-ups in new tab) is checked? 如何在不允许弹出窗口的情况下在新选项卡中打开网站? - how to open a website in a new tab without allowing pop-up in react?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM