开发者

Replace Integers in Code except formular values

开发者 https://www.devze.com 2023-04-05 08:39 出处:网络
I have a created a sortable with jQueryUI and after sorting I want to replace all integers in this code block with an other integer, except the integers in textarea, input and other form values. 开发者

I have a created a sortable with jQueryUI and after sorting I want to replace all integers in this code block with an other integer, except the integers in textarea, input and other form values. 开发者_如何学编程This is what I have:

$('.sortable').sortable({
    stop: function(event, ui) {
        ui.item.parent().find('li').each(function(index) {
            var new_html = $(this).html().replace(/\d+/g, (index + 1)).replace(/\d+/, (index + 2));
            $(this).html(new_html);
        });
    }
});

Help is greatly appreciated. Best regards, .wired


Sounds like a job for .not()

var tagsToReplace = $(this).children().not("input, textarea");
tagsToReplace.each(function(index) {
  $(this).html() = $(this).html().replace(/\d+/g, (index + 1)).replace(/\d+/, (index + 2));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消