JS 기초 조작

4745 단어 js
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); //      8

document.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 userAgent

8-14 screen  

8-15          

8-16         



HTML5  section ==div



wbr             progress  details       datalist      



form    keygen  


좋은 웹페이지 즐겨찾기