javascript初级

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 <script type="text/javascript">
  //  document.write("i love");
   function judy(){
       alert("hi,judy")
   } 
   //judy();
    function rec(){
       var message=confirm("你喜欢我吗");
       if(message==true){
           document.write("嗯,有眼光");
       }else{
           document.write("哼,我也不喜欢你");
       }
   } 
   //rec();

   function promptDemo(){
       var score=prompt("请输入分数");
       if(score>90){
           document.write("哇塞。学霸");
       }
       else if(80<score<90){
           document.write("80---90");
       }
       else if(score<80){
           document.write("我只笑笑不说话");
       }
   }

   function Wopen(){
       window.open('http://www.imooc.com','_self','width=300,height=200,menubar=no,toolbar=no,status=no,scollbars=yes')
   }
   function Wclose(){
       var mywon=window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no,status=no,scollbars=yes');
       mywon.close();
   }
   function zongjie(){
       var message=confirm("是否打开新窗口?");
       if(message==true){
           window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolbar=no');
       }else{
           alert("取消打开新窗口");
       }
   }
   function getId(){
       var mychar=document.getElementById("con");
     alert(mychar.innerHTML);
        mychar.style.color="red";
        mychar.style.backgroundColor="blue";
   }
   function hiddenContent(){
       var mychar=document.getElementById("con");
       mychar.style.display="none";
   }
   function showContent(){
       var mychar=document.getElementById("con");
       mychar.style.display="block";
   }

 </script> 
</head>
<body>
<form> 
<p id="con">i love javascript</p>

    <input type="button" value="点击我" onclick="judy()">
    <input type="button" value="再点一下" onclick="rec()">
    <input type="button" value="点第三下" onclick="promptDemo()">
    <input type="button" value="点击我,打开新窗口" onclick="Wopen()">
    <input type="button" value="关闭窗口" onclick="Wclose()">
    <input type="button" value="是否打开新窗口" onclick="zongjie()">
    <input type="button" value="通过id获取值" onclick="getId()">
    <input type="button" value="隐藏内容" onclick="hiddenContent()">
    <input type="button" value="显示内容" onclick="showContent()">
</form>  
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值