用jquery替换页面加载时DIV的内容

用jquery替换页面加载时DIV的内容,jquery,Jquery,使用jquery是否有一种方法可以在页面加载时获取DIV的内容并用其他内容替换它 <div class="content">Before</div> 之前 到 之后 使用 现场演示:以Curt的答案为基础,完整实现如下: $(document).ready( function() { $(".content").text("After"); }); 这将在加载窗口并更新所需div元素的内部文本时执行。**在worpdress中用jquery替换页面加载上的d

使用jquery是否有一种方法可以在页面加载时获取DIV的内容并用其他内容替换它

<div class="content">Before</div>
之前

之后
使用


现场演示:

以Curt的答案为基础,完整实现如下:

$(document).ready( function() {
    $(".content").text("After");
});

这将在加载窗口并更新所需div元素的内部文本时执行。

**在worpdress中用jquery替换页面加载上的div内容第一个替换div,第二个替换just text也加载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>

jQuery(函数($){
美元(“.yourclass”)。替换为(“新标题”);
});
**或用于文本替换**
jQuery(函数($){
$(“.single\u add\u to\u cart\u button”).text(“septe ekle”);
});
/*用于字符串替换*/
$(文档).ready(函数(){
var strNewString=$('body').html().replace(/\On-hold/g,'Processing');
$('body').html(strNewString);
});
示例:2
jQuery(“[lang='fr-fr'].label搜索选项”).each(函数(){
var text=jQuery(this.text();
text=text.replace(“所有类别”、“类别”);
jQuery(this).text(text);
});
$(document).ready( function() {
    $(".content").text("After");
});
    <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>