Jquery 将元素换行到新的div
我有以下代码:Jquery 将元素换行到新的div,jquery,Jquery,我有以下代码: var searchInput = '<md-input-container md-theme-watch="true" flex><label for="sampletext1">Champ texte</label><input name="sampletext1" type="text" class="ng-tree-search"&
var searchInput = '<md-input-container md-theme-watch="true" flex><label for="sampletext1">Champ texte</label><input name="sampletext1" type="text" class="ng-tree-search"></md-input-container>';
element.before($compile(searchInput)(scope))
.prev()
.on('keyup', function (ev) {
if (to) {
clearTimeout(to);
}
to = setTimeout(function () {
tree.jstree(true).search(ev.target.value);
}, 250);
});
我尝试了以下方法:
var searchInput = '<md-input-container md-theme-watch="true" flex><label for="sampletext1">Champ texte</label><input name="sampletext1" type="text" class="ng-tree-search"></md-input-container>';
var searchForm = element.before($compile(searchInput)(scope))
.prev()
.on('keyup', function (ev) {
if (to) {
clearTimeout(to);
}
to = setTimeout(function () {
tree.jstree(true).search(ev.target.value);
}, 250);
});
searchForm.wrap($compile('<div class="nrh-tree-search-container"></div>')(scope));
var searchInput='Champ texte';
var searchForm=element.before($compile(searchInput)(scope))
.prev()
.on('keyup',功能(ev){
若(至){
清除超时(to);
}
to=设置超时(函数(){
jstree(true).search(ev.target.value);
}, 250);
});
wrap($compile(“”)(scope));
但这不起作用,我在'
之外得到元素
我怎样才能解决这个问题
编辑:
演示:您应该这样尝试:
<div class="nrh-tree-search-container">
<md-input-container md-theme-watch="true" flex><label for="sampletext1">Champ texte</label><input name="sampletext1" type="text" class="ng-tree-search"></md-input-container>
<!-- element should be added here -->
</div>
检查方法:
$('.accordionTrigger p').wrapAll('');
wrapAll()方法将把匹配的所有元素包装到另一个元素中(与.wrap()方法分别包装匹配的元素相比)
$('.accordionTrigger p').wrapAll('<div class="moreInfo"></div>');