Search for text and replace it with Javascript

I am currently having some problems on my website, where I made a noob error from now on, and now it is getting big, and I'm still using an outdated system that I had in place at startup.

Basically, my site uses WordPress, and my download links are stored in the_content section of my site, and not in some form of custom meta, the worst part is they are not completely uniform only in the floor where I am having problems. (I searched most of the stack and other websites now for the source, to fix my problem, and no luck)

Here are some of my codes.

: 320 | 320 | 320 | iTunes | iTunes | iTunes
: CDQ | CDQ | CDQ | iTunes | iTunes | iTunes

Above what is usually displayed in the_content part of my website, it always leads with :and is accompanied by at least one link.

I need to replace all this part with <a href='download.php'>download</a>, the rest is already encoded, however my JavaScript knowledge is missing.

EDIT: Not sure what you mean by updating the expected output code, but here you go.

I want the content after DOWNLOAD: on my website to be replaced with the following:

Current:

<p style="text-align: center;"><strong>:</strong> <strong><a href="http://example.com">CDQ</a> | <a href="http://example.com">CDQ</a> | CDQ | <a href="http://example.com">iTunes</a> | <a href="http://example.com">iTunes</a> | iTunes</strong></p>

Perhaps this is important, it is always wrapped in a tag <p style="text-align: center;"> </p>!

Expected:

<a href='download.php'>download</a>
+4
source share
2 answers

If you want to make such a conclusion, it will help you also say what you want to change in this,

(function(){
        $('p.download-link a').fadeOut(function(){
            $(this).html('<a href="download.php">download</a>').fadeIn();
        });
    
        
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p style="text-align: center;" class="download-link"><strong>:</strong> <strong><a href="http://example.com">CDQ</a> | <a href="http://example.com">CDQ</a> | CDQ | <a href="http://example.com">iTunes</a> | <a href="http://example.com">iTunes</a> | iTunes</strong></p>
Run code

, .

+1

, Javascript , , .

/ MySQL, ?

Interconnect It PHP . .

, / , Interconnect It , , , , / .

:

<p style="text-align: center;"><strong>:</strong> <strong><a href="http://example.com">CDQ</a> | <a href="http://example.com">CDQ</a> | CDQ | <a href="http://example.com">iTunes</a> | <a href="http://example.com">iTunes</a> | iTunes</strong></p>

<p class="download_link_class"><a href="download.php">download</a></p>

, , , , - -... download_link_class class="", .

, , ! (staging/dev), , , .

0

Source: https://habr.com/ru/post/1688652/


All Articles