http://www.un.org。
如果你想保留一个变量中的内容,供日后插入,那么简单地将其储存在一个使用<代码>的变量中。
j Query s .contents(
)方法是选择所有内容,包括文本节点。
www.un.org/Depts/DGACM/index_spanish.htm Try it out:(click the text toggle)
这一实例将原始内容和新内容混为一谈。
var myVar;
// Add the new content, and append the element stored in myVar
$( #somediv ).toggle(function() {
myVar = $(this).contents();
$(this).html( some new content<br> );
}, function() {
$(this).html( myVar );
});
www.un.org/Depts/DGACM/index_spanish.htm
如果您使用<代码>.detach(>),你仍需要将其储存在一个变量中。
www.un.org/Depts/DGACM/index_spanish.htm http://jsfiddle.net/bD2Ej/“rel=”
// Detach and reference the element in a variable
myVar = $( #mySpan ).detach();
// Add the new content, and append the element stored in myVar
$( #somediv ).html( somecontent ).append( myVar );
但你是否确信需要<代码>.html(?>? 参见。 首先是字面上吗?