小编elm*_*mas的帖子

如何在jQuery中放置target ="_ blank"?

我尝试了许多变种来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")) …
Run Code Online (Sandbox Code Playgroud)

jquery dom

21
推荐指数
4
解决办法
8万
查看次数

标签 统计

dom ×1

jquery ×1