0

I am using WordPress and I want to replace some HTML on footer. I do not want to create a child theme for it. Just want to use simple JavaScript. Following is the code which is currently on website.

<div class="copyright">
Copyright 2016 
    <a href="www.myclientwebsite.com" title="My Client Title">
        <span>Client Company Name</span></a>.
Powered by
    <a href="http://wordpress.org" target="_blank" title="WordPress">
        <span>WordPress</span></a>.
Theme: by 
    <a href="http://thememakerwebsitelink.com/themename" target="_blank" title="Thememaker" rel="theme">
        <span>Theme Maker Name</span></a>.

Now I want to change all the HTML code inside the "copyright" div with my new HTML code using JavaScript. My new HTML code will be like it or whatever other.

<div class="copyright">
<div class="mynewdiv">
Copyright 2016
    <a href="www.myclientwebsite.com" title="My Client Title">
        <span>Client Company Name</span></a>.
Website Designed by
    <a href="http://www.mywebsite.com/">My Company Name</a>
</div>

I used a code for this it works but not support HTML.

<script type="text/javascript">document.getElementsByClassName('copyright')[0].replaceWith("Text without HTML");    

I want simple JavaScript code where I can simply type my new HTML code.

Please let me know How can I do it.

1 Answer 1

2
var yourHTML = '<div class="mynewdiv">Copyright 2016<a href="www.myclientwebsite.com" title="My Client Title"><span>Client Company Name</span></a>. Website Designed by<a href="http://www.mywebsite.com/">My Company Name</a></div>';
document.getElementsByClassName('copyright')[0].innerHTML = yourHTML;
// If you change your HTML, change the value of yourHTML
Sign up to request clarification or add additional context in comments.

1 Comment

then you might want to accept the answer to give the credit to the one who helped you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.