Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript问题。需要有关循环和.append的帮助吗_Javascript_Jquery_Append - Fatal编程技术网

Javascript问题。需要有关循环和.append的帮助吗

Javascript问题。需要有关循环和.append的帮助吗,javascript,jquery,append,Javascript,Jquery,Append,我需要一个搜索结果页面。此搜索结果页是一个表。我无法更改页面的html。这是html: <table class="product-table"> <tr> <td> <dl> <dt> <h1>Item</h1> </dt>

我需要一个搜索结果页面。此搜索结果页是一个表。我无法更改页面的html。这是html:

<table class="product-table">
    <tr>
        <td>
            <dl>
                <dt>
                    <h1>Item</h1>
                </dt>

                <dd class="title fn">
                    <a class="url" href="/product.jsp?id=EHS_FR_BS-PK-409674&amp;navAction=jump&amp;navCount=0">
                        Pratique de l'accouchement, 5ème Edition
                    </a>
                </dd>
            </dl>
        </td>
    </tr>
    <tr>
        <td>
            <dl>
                <dt>
                    <h1>Item</h1>
                </dt>

                <dd class="title fn">
                    <a class="url" href="/product.jsp?id=EHS_FR_BS-PK-409674&amp;navAction=jump&amp;navCount=0">
                        Pratique de l'accouchement, 5ème Edition
                    </a>
                </dd>
            </dl>
        </td>
    </tr>
</table>

项目
项目
我的问题

但我想在dd类标题fn。新元素。此元素是指向页面更多信息的链接。该元素必须获取a class=url元素的href

我制作了以下javascript:

 $("table.product-table .pricing").append('<a class="information" href="" title="plus d’information">plus d’information</a>');
$(“table.product-table.pricing”).append(“”);
但我怎样才能更好地解决这个问题呢。以及如何将类url的href放入我附加的新a元素中

你明白我的问题吗

谢谢你的帮助

$(“dd.title.fn”)。每个(函数(){
$("dd.title.fn").each(function() {
    var $this = $(this);
    $this.append('<a class="information" href="' + $this.find(".url").attr("href") + '" title="plus d’information">plus d’information</a>');
});
var$this=$(this); $this.append(“”); });
这对你有帮助吗?查看此链接,了解有关每个方法的更多信息,这些方法可能会帮助您获取要附加的每个链接的url


为什么在jquery选择器中使用“定价”类?这些元素似乎不存在于您给定的HTMLY中。您已经有了到资源的链接,为什么要复制它?