gpt4 book ai didi

jquery - 如何将目标 ="_blank"放入 jQuery 中?

转载 作者:行者123 更新时间:2023-12-03 21:42:53 24 4
gpt4 key购买 nike

我尝试了多种变体,将 target="_blank" 放入 jQuery 的链接中,但我无法让它工作。

这是我的代码:

var thumbfile = "<?php echo $smit_iturl_v; ?>";
jQuery(document).ready(function () {
var actualHost = jQuery.trim(jQuery.url.attr("host"));
jQuery("a img").each(function (i) {

if (jQuery.trim(jQuery.url.setUrl(jQuery(this).attr("src")).attr("host")) == actualHost &&
(jQuery.url.setUrl(jQuery(this).attr("src")).attr("path")).indexOf("wp-content") != -1 &&

isImage(jQuery.url.setUrl(jQuery(this).attr("src")).attr("file"))) {

var parentTag = jQuery(this).parent().get(0).tagName;
parentTag = parentTag.toLowerCase();

if (parentTag == "a" &&
jQuery.url.setUrl(jQuery(this).parent().attr("href")).attr("host") == actualHost &&
jQuery.url.setUrl(jQuery(this).parent().attr("href")).attr("path").indexOf("wp-content") != -1 &&
isImage(jQuery(this).parent().attr("href"))) {

var description = (jQuery(this).attr("alt") == "") ? jQuery(this).attr("title") : jQuery(this).attr("alt");
jQuery(this).parent().attr("href", thumbfile +
"?title=" + jQuery(this).attr("title") +
"&description=" + description +
"&url=" + stripDomain(jQuery(this).parent().attr("href"))

);
}
}
});

我该怎么做?

最佳答案

信息太多了!这应该可以正常工作:

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

请参阅此处的示例 http://jsbin.com/evexi/edit 。它运行完美。

关于jquery - 如何将目标 ="_blank"放入 jQuery 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1933501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com