gpt4 book ai didi

javascript - 添加新的滚动内容(克隆)到 jQuery UI slider ?

转载 作者:行者123 更新时间:2023-11-28 08:54:23 24 4
gpt4 key购买 nike

因此,我在 fiddle 中有一个类似于以下内容的 slider ,需要选择添加新内容( block 或滚动内容项)。添加后,我将进行内联编辑来更改以下文本,但我更希望在克隆 block 时,其中没有以前的数字或文本。提前致谢。 http://jsfiddle.net/4QEgr/1/

$(".addNew").on("click", function(event){
//clone last block
//add new block to slider div
});

我的内容项包含此内容,我需要在克隆时清除标签。

<div class="scroll-content-item ui-widget-header folder1">
<span class="glyphicon glyphicon-folder-close icon-set" title='Folder1'>
<label class='folderLbl'>Folder1</label>
</span>
</div>

最佳答案

只需使用这个:

$(".addNew").on("click", function (e) {
scrollContent.append(function(){
return $(this).find('.ui-widget-header:last')
.clone()
.text(function(i, h){
return parseInt(h, 10)+1;
});
});
});

当点击.addNew时,它会获取最后一个.ui-widget-header block ,克隆它,增加数字并将其附加到.scroll -content 容器 div。

这里正在工作:http://jsfiddle.net/v3K3m/

更新:

如果您的示例 HTML block 是:

<div class="scroll-content-item ui-widget-header folder1">
<span class="glyphicon glyphicon-folder-close icon-set" title='Folder1'>
<label class='folderLbl'>Folder1</label>
</span>
</div>

然后你可以使用:

$(".addNew").on("click", function (e) {
scrollContent.append(function () {
return $(this).find('.ui-widget-header:last')
.clone()
.find('.folderLbl')
.html(function (i, h) {
return 'Folder' + (parseInt(h.match(/\d+$/), 10)+1);
}).parents('.ui-widget-header');
});
});

这里正在工作:http://jsfiddle.net/ybmYD/

关于javascript - 添加新的滚动内容(克隆)到 jQuery UI slider ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18700845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com