[英]jQuery .load to load SOME of the contents of a div from another page
[英]Replace contents of DIV on page load with jquery
使用 jquery 有没有一种方法可以获取 DIV 的内容并在页面加载时将其替换为其他内容?
<div class="content">Before</div>
到
<div class="content">After</div>
为了搭载 Curt 的回答,完整的实现是这样的:
$(document).ready( function() {
$(".content").text("After");
});
这将在窗口加载并更新所需 div 元素的内部文本时执行。
**用 worpdress 中的 jquery 替换页面加载时 DIV 的内容 第一个替换 DIV,第二个替换仅文本 还加载 jQuery 字符串替换 **
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.