码迷,mamicode.com
首页 > 其他好文 > 详细

$().thml()与$().text()的区别

时间:2014-07-27 23:41:29      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:.thml与.text的区别

<1>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://localhost:41928/Jquery/jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        
        $(function () {
            //.thml()是在块中加html代码
            $("div").html("<a href='http://www.baidu.com'>百度</a>"); 
            alert($("div").text());  //输出是是一个百度的超链接
        })

        $(function () {
            //.text()是在块中的文字
            $("div").text("<a href='http://www.baidu.com'>百度</a>");
            alert($("div").text()); //输出的是 【<a href='http://www.baidu.com'>百度</a>】这么一段文字
        })

      
    </script>
</head>
<body>
<div></div>

</body>
</html>

bubuko.com,布布扣bubuko.com,布布扣



http://blog.sina.com.cn/s/blog_561be372010008ev.html

$().thml()与$().text()的区别,布布扣,bubuko.com

$().thml()与$().text()的区别

标签:.thml与.text的区别

原文地址:http://blog.csdn.net/fanbin168/article/details/38186569

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!