您的位置:首页 > Web前端 > JQuery

jQuery--包裹节点

2015-08-17 10:11 567 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>Untitled Document</title>

        

        <script type="text/javascript" src="jquery-1.7.2.js"></script>

        <script type="text/javascript">

        

            //测试包装wrap ,wrapAll(),wrapInner

            $(function(){

                

                //wrap li本身

                //$("#city li").wrap("<font color='red'></font>");

                //wrapAll 所有的li

                //$("#city li").wrapAll("<font color='red'></font>");

                //wrapWith 包裹li里面的文字

                $("#city li").wrapInner("<font color='red'></font>");

            })                

        </script>

        

    </head>

    <body>

        <p>你喜欢哪个城市?</p>

        <ul id="city">

            <li id="bj" name="BeiJing">北京</li>

            <li>上海</li>

            <li id="dj">东京</li>

            <li id="se">首尔</li>

        </ul>

        

        <br><br>

        <p>你喜欢哪款单机游戏?</p>

        <ul id="game">

            <li id="rl">红警</li>

            <li>实况</li>

            <li>极品飞车</li>

            <li>魔兽</li>

        </ul>

        

        <br><br>

        <p>你喜欢哪种开发语言?</p>

        <ul id="language">

            <li>C</li>

            <li>Java</li>

            <li>.NET</li>

            <li>PHP</li>

        </ul>

        

        <br><br>

        gender:

            <input type="radio" name="gender" value="male"/>Male

            <input type="radio" name="gender" value="female"/>Female

    

        <br><br>

        name: <input type="text" name="username" value="atguigu"/>

        

    </body>

</html>   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: