Using jquery is there a way I can take the contents of a DIV and replace it with something else when the page loads?
Before
**Replace contents of DIV on page load with jquery in worpdress 1st one replace DIV and 2nd replace just text Also Onload jQuery String Replace **
<script type="text/javascript">
jQuery(function($){
$( ".yourclass " ).replaceWith( "<h6>New heading</h6>" );
});
</script>
**OR For text replace**
<script type="text/javascript">
jQuery(function($){
$( ".single_add_to_cart_button " ).text( "Sepete ekle" );
});
</script>
/* For String Replace */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var strNewString = $('body').html().replace(/\On hold/g,'Processing');
$('body').html(strNewString);
});
EXAMPLE : 2
jQuery("[lang='fr-FR'] .label-search option").each(function() {
var text = jQuery(this).text();
text = text.replace("All Category", "Catégories ");
jQuery(this).text(text);
});
</script>
Use text():
$(".content").text("After");
Live Demo: http://jsfiddle.net/heY3j/
To piggyback off of Curt's answer the full implimentation for this would be this:
$(document).ready( function() {
$(".content").text("After");
});
This will execute when the window has been loaded and update the inner text of the desired div element.