Javascript的问题.需要loop和.append的帮助
Javascript issue. Need help with a loop and .append
是一个搜索结果页面。这个搜索结果页面是一个表格。我无法更改页面的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&navAction=jump&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&navAction=jump&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>');
但是我怎样才能更好地解决这个问题呢?我怎么能把类url的href在新的一个元素,我追加。
你明白我的问题吗?谢谢你的帮助!
$("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>');
});
这个对你有帮助吗?查看此链接以获取有关each
方法的更多信息,这可能有助于您获得想要附加的每个链接的url。
相关文章:
- 需要帮助设置json数组
- JQuery需要帮助理解(i,el)
- 如何在输入字段中的按钮的帮助下打开日历,该字段的类型为“=”;日期”;
- 需要帮助谷歌地图方向面板在FancyBox中显示
- 我需要为我的朋友在这个项目上提供帮助
- 使用密码对话框Javascript请求帮助
- JavaScript计算帮助(乘以时间)
- 另一个if(!$scope.$$phase)$scope$apply()szenario-需要帮助才能通关
- 在刚刚调用的append函数之后,jquery.height()不会返回实际值
- Javascript - element.childNodes does not see an append.newch
- append元素don'不要在提交时出现
- Jquery append oly获取循环Rails中的最后一个elemen
- Angular ng类需要帮助设置
- {{#each}}内部的Handlebar帮助程序
- 如何在yii中使用append
- 文本编辑后,append函数不适用于文本区域
- MutationObserver observe jquery append?
- php帮助-需要使用字符串回显php
- 使用append时复制内容的DOM
- Javascript的问题.需要loop和.append的帮助