如何将html代码放入jQuery或JavaScript的append中?
如何在jquery的append中放入html,在网页中追加Div如何将html代码放入jQuery或JavaScript的append中?,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,如何在jquery的append中放入html,在网页中追加Div $('.oo').append( <div style="width:100%; min-height:35px; max-height:auto; margin-top:10px;"> <div style="height:auto; margin:2px 2px 2px 16px;">
$('.oo').append(
<div style="width:100%; min-height:35px; max-height:auto; margin-top:10px;">
<div style="height:auto; margin:2px 2px 2px 16px;">
<img src="image/xprin_load2_loader.gif" style="float:left; height:35px; width:35px; border-radius:5%;"/>
</div>
<div style="height:auto; margin: 5px 5px 5px 55px; text-align:left; box-shadow: 3px 0px 0px #4080ff;">
<b>: </b>
<span style="margin:2px 2px;"></span>
</div>
</div>
);
$('.oo')。追加(
:
);
像这样做
$('.oo').append(
'<div style="width:100%; min-height:35px; max-height:auto'
+'; margin-top:10px;">
<div style="height:auto; margin:2p'
+'x 2px 2px 16px;">
<img src="image/xprin_load2_loader.gif'
+'" style="float:left; height:35px; width:35px; border-radius:5%;"/>
'
+' </div>
<div style="height:auto; margin:'
+' 5px 5px 5px 55px; text-align:left; box-shadow: 3px 0px 0px #4080ff;"'
+'>
<b>: </b>
<span style="margin:2px 2p'
+'x;"></span>
</div>
</div>');
$('.oo')。追加(
'
'
+'
:
');
它将起作用。您只需在要附加的html周围添加引号即可
$('.oo').append(
' <div style="width:100%; min-height:35px; max-height:auto; margin-top:10px;">' +
+' <div style="height:auto; margin:2px 2px 2px 16px;">' + ' <img src="image/xprin_load2_loader.gif" style="float:left; height:35px; width:35px; border-radius:5%;"/>' + '</div>' + '<div style="height:auto; margin: 5px 5px 5px 55px; text-align:left; box-shadow: 3px 0px 0px #4080ff;">' + '<b>: </b>' + '<span style="margin:2px 2px;"></span>' + '</div>' + '</div>'
);
$('.oo')。追加(
' ' +
+' ' + ' ' + '' + '' + ': ' + '' + '' + ''
);
在要添加的html周围添加引号RTD:还建议您使用样式表,而不是使用内联样式来扩展html。除了按照Rory的建议使用样式表和类之外,我还强烈建议您从硬连接的html转移到任何形式的模板系统。作为模板编写和维护HTML要容易得多。