Js基礎操作

來源:互聯網
上載者:User

標籤:

var a="zhangsan";  document.write(a+":I love JavaScrip");  a="lisi";  document.write("<br/>");  document.write(a+":I love JavaScrip");  alert(‘haha‘);函數的編寫 function test(){    var mymessage=confirm("你喜歡JavaScript嗎?");    if(mymessage==true)    {   document.write("很好,加油!");   }    else    {  document.write("JS功能強大,要學習噢!");   }  } function test()  {  var con=confirm("你缺點需要退出網站嗎?");if(con==true){document.write("你端機確定額!");}else{document.write("你端機確定額!");}  }--------------------------------function test1()  {  var myname=prompt("請輸入你的姓名:");if(myname!=null)  {   alert("你好"+myname); }else  {  alert("你好 my friend.");  }  }-------------------開啟關閉  var a=window.open(‘http://www.imooc.com‘,‘_blank‘,‘width=300,height=200,menubar=no,toolbar=no, status=no,scrollbars=yes‘);  a.close();-----------------------dom節點操作 function test3()  { var d=document.getElementById("hh").innerHTML;  document.write(d);  屬性節點操作     function test5()  { var d=document.getElementById("hh1");  d.style.color="black" ;  d.style.background="gray";  d.style.fontFamily="微軟雅黑";  d.style.fontSize=20;    }---------------顯示隱藏  function test6()  {  var d=document.getElementById("dis").style.display="none";  }   function test7()  {  var d=document.getElementById("dis").style.display="block";  }修改類名<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>className屬性</title><style>    body{ font-size:16px;}    .one{border:1px solid #eee;width:230px;height:50px;background:#ccc;color:red;    }.two{border:1px solid #ccc;width:230px;height:50px;background:#9CF;color:blue;}</style></head><body>    <p id="p1" > JavaScript使網頁顯示動態效果並實現與使用者互動功能。</p>    <input type="button" value="添加樣式" onclick="add()"/><p id="p2" class="one">JavaScript使網頁顯示動態效果並實現與使用者互動功能。</p>    <input type="button" value="更改外觀" onclick="modify()"/><script type="text/javascript">   function add(){      var p1 = document.getElementById("p1");      p1.className="two";   }   function modify(){      var p2 = document.getElementById("p2");    p1.className="one";         }</script></body></html>js變數 什麼是變數 定義 運算式 賦值 自增自減 ++--比較運演算法 邏輯運算髮  是非顛倒 操作運算子數組 組團  數組賦值  數組添加元素  使用數組元素 數組數量  二維數組流程式控制制語句  if if else switch for while do break conitinute函數  函數定義  有參函數 帶傳回值函數事件 單機事件 滑鼠經過 移開 游標聚集 內容選中 內容改變 載入事件 卸載事件js內建對象什麼是對象date對象  返回設定年份方法 返回星期方法 返回設定時間方法  返回指定字元  返回字串首次出現的位置  字串分割 split()  提取字串substring()  提取指定數目的字元substr()  Math對象向上取整ceil() 鄉下取整floor() 四捨五入round() 隨機數random() array數組對象()數組裡阿尼額concat()  指定分隔字元連結數組元素join()window對象 js計時器  計算機setInterval()  取消clearInterval()  計時器setTimeout()取消計時器  clearTimeout()History對象 返回前一個下一個頁面 返回瀏覽曆史中其他頁面賦值多元化:var num1 = 123;       // 123是數值var num2 = "一二三";    //"一二三"是字串var num3=true;   數組的使用var myarr=new Array(); //定義數組 myarr[0]=80;  myarr[1]=60; myarr[2]=99;var myarray= new Array(8); //建立數組,儲存8個資料var myarray = new Array(66,80,90,77,59);//建立數組同時賦值 var myarray = [66,80,90,77,59];//直接輸入一個數組(稱 “字面量數組”)myarray[5]=88; //使用一個新索引,為數組增加一個新元素var arr=[55,32,5,90,60,98,76,54];//包含8個數值的數組arr document.write(arr.length); //顯示數組長度8document.write(arr[7]); //顯示第8個元素的值54二維數組  var myarr=new Array();  //先聲明一維 for(var i=0;i<2;i++){   //一維長度為2   myarr[i]=new Array();  //在聲明二維    for(var j=0;j<3;j++){   //二維長度為3   myarr[i][j]=i+j;   // 賦值,每個數組元素的值為i+j   }      document.write("二維數組:"+myarr);if語句的使用 var mycarrer = "HTML";  if (mycarrer == "HTML")  {    document.write("你面試成功,歡迎加入公司。");  }顛倒數組元素順序reverse()  選定元素slice()  數組排序sort()8-11 Location對象8-12 Navigator對象8-13 userAgent8-14 screen對象8-15 螢幕解析度的高和寬8-16 螢幕可用高和寬度HTML5  section ==divwbr響應式布局  換列標籤  progress  details標籤 縮放  datalist  自動提示form表單下的keygen加密

 

Js基礎操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.