用jQuery替换页面加载时DIV的内容 [英] Replace contents of DIV on page load with jquery

查看:110
本文介绍了用jQuery替换页面加载时DIV的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jquery是否可以获取页面中加载的DIV内容并将其替换为其他内容?

Using jquery is there a way I can take the contents of a DIV and replace it with something else when the page loads?

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

<div class="content">After</div>

推荐答案

使用 text():

$(".content").text("After");

实时演示: http://jsfiddle.net/heY3j/

这篇关于用jQuery替换页面加载时DIV的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆