'Replace WP logo with H1 using JS

I need to replace site_logo(); with the_title( '<a href="http://example.com/"><h1 class="entry-title">', '</h1></a>' ); using JS if possible, so that I don't edit the header.php directly. Thanks in advance.



Solution 1:[1]

You can use replaceWith

$("h1").replaceWith('<a href="http://example.com/"><h1 class="entry-title">replaceWith</h1></a>');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Test</h1>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SKJ