(039)jquery_dom选择器_replaceWith_replaceAll

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>dom_replaceWith.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <style type="text/css">
        span
        {
            color: White;
            padding: 8px
        }
        .red
        {
            background-color: Red;
        }
        .green
        {
            background-color: green;
        }
    </style>
    <script type="text/javascript" src="../js/jquery/jquery190.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var $html = "<span class='red' title='hi'>我是土豪</span>";
            $(".green").replaceWith($html);
        });
    </script>
  </head>
  
  <body>
        <span class='green' title='hi'>我是程序员</span>
  </body>
</html>

 

$(selector).replaceWith($content)

$(content).replaceAll(selector)

posted @ 2014-12-18 08:56  雪中飞雁  阅读(90)  评论(0)    收藏  举报