开发者

Replace Integers in Code except formular 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜