• jquery学习


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript" src="jquery-1[1].2.6.js"></script>
    <script  type="text/javascript">
    // $(document).ready(function(){
    // jQuery(function($) {
    $(function(){

        var option1 = "<OPTION value='";  
        var option2 = "'>";  
        var option3 = "</OPTION>";
       $("#divZ2").append("<strong>This is just added</strong>");
        var value =5;  
            var text =5;  
       $("#year1").append(option1 + value + option2 + text + option3);
       $("a").click( function(){alert("OK");});
       $("div>p").css("color","red");
       $("div>p").addClass("testclass");
      
       $(".stripe_tb tr").mouseover(function(){
    //如果鼠标移到class为stripe_tb的表格的tr上时,执行函数
    $(this).addClass("over");}).mouseout(function(){
    //给这行添加class值为over,并且当鼠标一出该行时执行函数
    $(this).removeClass("over");}) //移除该行的class
    $(".stripe_tb tr:even").addClass("alt");
    //给class为stripe_tb的表格的偶数行添加class值为alt
    $('a.affLink').mouseover(function(){window.status=this.title;return true;});
    $('a.affLink').mouseout(function(){window.status='Done';return true;});
    $("#Btn").click( function()
     {
      $(".MyTest").slideDown("slow"); });
     
    });


    </script>
    <script type="text/javascript">
    function jq(){ 
        alert($("div > p").html()); 
    }
    function appendToelemt(){
        $("<div><p>Hello</p></div>").appendTo("body");
    }
    </script>
    <style>
    <style>
    red {
            background:#0066FF;
            color:#FFFFFF;
            line-height:20px;
            height:30px;
    }
    blue{
            background:#3399FF;
            color:#FFFFFF;
            line-height:20px;
            height:30px;
    }
    green{
            background::#FF00FF;
            color:#FFFFFF;
            line-height:20px;
            height:30px;
      
    }
    .testclass { background: yellow; font-size: 20pt; }


    /*注意选择器的层叠关系*/
    .stripe_tb th {
    background:#B5CBE6;
    color:#003399;
    line-height:20px;
    height:30px;
    }
    .stripe_tb td {
    padding:6px 11px;
    border-bottom:1px solid #95bce2;
    vertical-align:top;
    text-align:center;
    }
    .stripe_tb td * {
    padding:6px 11px;
    }
    .stripe_tb tr.alt td {
    background:#ecf6fc; /*这行将给所有偶数行加上背景色*/
    }
    .stripe_tb tr.over td {
    background:#FEF3D1; /*这个将是鼠标高亮行的背景色*/
    }
    .MyTest{display: none;}
    </style>
    </style>
    </head>

    <body>
    <a href="#">CHM</a>
    <p>one</p> <div><p>two</p></div> <p>three</p>
    <table class="stripe_tb" width="50%" border="0" cellspacing="0" cellpadding="0  ">
      <!--用class="stripe_tb"来标识需要使用该效果的表格-->
      <thead>
      <tr>
      <th>姓名</th>
      <th>年龄</th>
      <th>MSN</th>
      <th>Email</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      <tr>
      <td>Robin</td>
      <td>50</td>
      <td>rlog@live.com</td>
      <td><a href="http://rlog.cn">Rlog</a></td>
      </tr>
      </tbody>
      </table>
    <a onMouseOver='window.status="http://www.merchant-url-here.com";
    return true;' onMouseOut='window.status="Done"; return true;'
    href="http://www.affiliate-url-here.com"
    target="_blank">Link Text Here</a>
    <p><a href="http://www.affsite.com?id=123"
     title="http://www.173.com"
    class="affLink">Super Duper Product</a></p>
    <input  type="button" onclick="" id="Btn"/>
    <div class="MyTest">
    <p>1</p>
    <p>2</p>
    <p>3</p>
    <p>4</p>
    </div>
    <p>one</p>
    <div>
          <p>two</p>
    </div>
        <p>three</p>
        <a href="#" id="test" onClick="jq()" >jQuery</a>
    <input  type="button" onclick="Cl()" />
    <script type="text/javascript">
    function Cl()
    {

     for (var i=2006;i<2008;i++)
     {
       alert(i);
     }
     
    }
    function getyear1(value)
       {
        var option1 = "<OPTION value='";  
        var option2 = "'>";  
        var option3 = "</OPTION>";
         
           if (value != 0)
                    {
                         var now = new Date();
                         var max=now.getYear();
                         var min=value;
                        for(var i=min; i<=max; i++)
                    {
             //$("#year1").append("<option value='"+i+"'>"+i+"</option>");
            var value =i;  
            var text =i;  
       $("#year1").append(option1 + value + option2 + text + option3);
                            //document.all("year1").options.add(new Option(i,i));
                      document.all("year2").options.add(new Option(i,i));
                         
                    }
                    } 
                        
                   
                  
     }
      function hideeelent()
      {
     
        $("#testDiv").hide();

      }
      function specify(current)
      {
             var spName = $(current+" option:selected").val();
             alert(spName);
      }
      function deleteelent()
      {
     
       if (  $("#myTable").length >0 )
       {
          $("#myTable").remove();; 
     } else
     {
     
          $("<div id='foo'><p>Hello222</p></div>").appendTo("body");
      $("p").appendTo("#foo");
     }
      }
       
    </script>
    <select id="year1"></select>
    <select id="year2"></select>
    <input  type="button" onclick="getyear1(2004)"  value="add items"/>
    <input  type="button" onclick="specify(year2)" />
    <script language="JavaScript">
    <!--
    function add_select_option(obj, text, value){
        try{
            obj.add(new Option(text, value));
        }catch(e){
            obj.add(new Option(text, value), null);
        }
    }
    function append_option(){
        var obj = document.getElementById("sel_test");
        for (var i=0; i<10; i++)
     {
            var text = "这是 "+i;
            var value = i;
            add_select_option(obj, text, value)
        }
    }
    //-->
    </script>
    <select id="sel_test" name="sel_test"></select>
    <input type="button" onclick="append_option()" value="btn_test">
    <div id="divZ2">
      <h2>Original Text 2</h2>
    </div>

    <div id="testDiv">
    <table id="myTable">
      <tr><td>Value 1</td><td></td></tr>
      <tr><td>Value 2</td><td></td></tr>
    </table>
    </div>
    <input  type="button" onclick="deleteelent()" value="删除元素"/>
    <input  type="button" onclick="hideeelent()" value="隐藏元素"/>

    </body>

    </html>

  • 相关阅读:
    AutoLISP修改圆直径
    AutoLISP文字加上下划线
    EminemNot Afraid
    AutoLISP将图形中文字写入外部文件
    AutoLISP文字大小写转换
    AutoLISP修改文字高度
    AutoLISP文字外加矩形框
    AutoLISP文字外加圆形框
    AutoLISP纹理地板图案
    AutoLISP修改文字倾斜角度
  • 原文地址:https://www.cnblogs.com/chenghm2003/p/1264704.html
Copyright © 2020-2023  润新知