如果内容被添加到DOM中,例如,
$("ul").append("<li>test</li>");
从append()方法分配返回值是jQuery对象.
var newContent=$("ul").append("<li>test</li>");
可以做的
var newContent=$("ul li:last");
但是有没有办法让它更直接?
谢谢
@R_404_323@
使用
.appendTo():
Insert every element in the set of matched elements to the end of the target…
The 07001 and
.appendTo()
methods perform the same task. The major difference is in the Syntax-specifically,in the placement of the content and target. With.append()
,the selector expression preceding the method is the container into which the content is inserted. With.appendTo()
,on the other hand,the content precedes the method,either as a selector expression or as markup created on the fly,and it is inserted into the target container…