PSD to HTML conversion PSD to HTML conversion PSD2HTML.com with over 300 professionals takes the designs to HTML and beyond

Code Snippet

Home » Code Snippets » jQuery » Search/Replace

Search/Replace

jQuery(function () {
    jQuery(":contains(FIND)").not(":has(:contains(FIND))").each(function () {
        var that = $(this),
            html = that.html(); 

        html = html.replace(/(\(FIND:.*?\))/g, "REPLACE-WITH");
        that.html(html);
    });
});

Reference URL

Subscribe to The Thread

  1. That is so over-complicated.

    • I think the only reasonable response to that is…
      “Put up or shut up.” Let’s see your alternative.

    • I would if I could work out how to post code into these comment blocks.

    • This would be javascript, so no special formatting is needed at all. Just put it in between <pre><code> tags. If it comes out fucked up, I fix it.

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~