[英]Inserting multiple elements using jquery .html
I'm currently using jquery .html
for DOM insertion. 我目前正在使用jquery
.html
进行DOM插入。 Is there a way I can insert multiple elements? 有没有办法插入多个元素?
So far I have tried using &&
or even using a comma inserting multiple elements but none of them seems to be feasible. 到目前为止,我已经尝试使用
&&
甚至使用逗号插入多个元素,但是似乎都不可行。 Separating it would also likely not work. 分开它也可能行不通。
$('#header .aim-breadcrumbs').html($('.layout-container .region-breadcrumb') && $('#header .aim-nav .connect'));
$('#header .aim-breadcrumbs').html($('.layout-container .region-breadcrumb', '#header .aim-nav .connect');
$('#header .aim-breadcrumbs').html($('.layout-container .region-breadcrumb');
$('#header .aim-breadcrumbs').html($('#header .aim-nav .connect');
You are really close. 你真的很亲近 You just need to put the comma inside your selector string.
您只需要将逗号放在选择器字符串中即可。 Don't use two strings.
不要使用两个字符串。
$('#header .aim-breadcrumbs').html($('.layout-container .region-breadcrumb, #header .aim-nav .connect'));
This will work, but as everyone is already shouting, .append
is the typical way of doing this. 这将起作用,但是由于大家已经大喊大叫,
.append
是执行此操作的典型方法。
$('#header .aim-breadcrumbs').append($('.layout-container .region-breadcrumb, #header .aim-nav .connect'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.