【发布时间】:2017-03-01 05:29:36
【问题描述】:
我有一个包含这样的列表元素的列表...
<li class="first leaf">
<a href="/admin/store/orders/view" title="View and process the orders.">View orders</a>
</li>
我想获取 title 属性并将其作为 div 附加在 <a> 之后,就像这样...
<li class="first leaf">
<a href="/admin/store/orders/view" title="View and process the orders.">View orders</a>
<div>View and process the orders.</div>
</li>
到目前为止,我在这里......
(function ($) {
$('#block-menu-menu-admin-welcome li a').each(function () {
$(this).append('<div>' + $(this).attr('title') + '</div>');
});
})(jQuery);
但它不起作用。有人可以帮忙吗?
【问题讨论】:
-
您想要
.after()而不是.append()?.after()works fine for me
标签: javascript jquery html attributes jquery-append