Skip to content Skip to sidebar Skip to footer

Get Invalid Html Code In Curly Brackets With Jquery

I have some (invalid) HTML code which I cannot change: ...... With jQuer

Solution 1:

So, basically you want to get the 'outer' html and then search for whats in between the curly braces.

The first part of that has been solved here

Get selected element's outer HTML

So using the outerHTML plugin from that question

jQuery.fn.outerHTML = function(s) {
    return s
        ? this.before(s).remove()
        : jQuery("<div>").append(this.eq(0).clone()).html();
};

functionsomeFunction(id) {
  return $('#text'+id).outerHTML().match(/{(.*)}/)[1];
}

Post a Comment for "Get Invalid Html Code In Curly Brackets With Jquery"