dom 删除和清除

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script type ="text/javascript">
        $(function () {
            $("input[type=button]:eq(0)").click(function () {
                $("<a href='#'>insertBefore</a>").insertBefore(this);
            });
            $("input[type=button]:eq(1)").click(function () {
                $("<a href='#'>insertAfter</a>").insertAfter(this);
            });
            $("input[type=button]:eq(2)").click(function () {
                $(this).after("<a href='#'>after</a>");
            });
            $("input[type=button]:eq(3)").click(function () {
                $(this).before("<a href='#'>before</a>");
            });
        });
    </script>
</head>
<body>
    <select id="selNation">
        <option value ="1">中国</option>
        <option value ="2">美国</option>
        <option value ="3">德国</option>
    </select>
    <input type ="button" value="insertBefore"/>
      <input type ="button" value="insertAfter"/>
      <input type ="button" value="after"/>
      <input type ="button" value="before"/>
</body>
</html>

  

posted @ 2014-06-13 23:51  编程猴子  阅读(668)  评论(0编辑  收藏  举报