Jquery html encode & decode

来源:互联网 发布:网络销售是干什么的 编辑:程序博客网 时间:2024/04/28 21:55
<script type="text/javascript">                      $(document).ready(function(){                        function htmlEncode(value){                          //create a in-memory div, set it's inner text(which jQuery automatically encodes)                          //then grab the encoded contents back out.  The div never exists on the page.                          return $('<div/>').text(value).html();                        }                        function htmlDecode(value){                          return $('<div/>').html(value).text();                        }                        $("div#content").html(htmlDecode("<{$theart[theart].content}>"));                        console.log(htmlDecode("<{$theart[theart].content}>"));                        // $("#content").html("<p>test</p>");                      });                    </script>

0 0
原创粉丝点击