1.html()方法

3.2.10 设置和获取HTML,文本和值 

1.html()方法 

此方法类似于JavaScript中的innerHTML属性,可以用来读取或者设置某个元素中的HTML内容的 

为了更清楚地展示效果,将<p>元素的HTML代码改成:
node2:/var/www/html/jquery#cat t35.html 
<p title="选择你最喜欢的水果."><strong>你最喜欢的水果的是?</strong></p>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>    
<script type="text/javascript" src="t35.js"></script>

node2:/var/www/html/jquery#cat t35.js 
var p_html = $("p").html(); //获取<p>元素的HTML代码
console.log(p_html);
alert(p_html);

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/89884123
今日推荐