day01作业

1、通过js获取输入框中的value值

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title>通过js获取输入框的value值</title>
</head>
<body>
    <label>
    电话:
    <input type="text" id="phone" value="phonenumber">
    <input type="button" name="button1" value="提交" onclick="f()">
    	
    </label>


    <script type="text/javascript">
    	function f(){
    		var b=document.getElementById('phone');
    		console.log(b);

    		var a=document.getElementById('phone').value;
    		console.log(a);
    	}

    </script>

</body>
</html>

2、点击某个元素,更改该元素的样式

index1.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title>第2题</title>
	<style type="text/css">
		div{
			height: 100px;
		}
	</style>
	<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>

<p onclick="this.innerHTML='1'">点击改变1</p>
<div onclick="a(this)" style="width: 150px;">点击改变2</div>
<div onclick="b(this)" style="width: 100px;">点击改变3</div>

<script type="text/javascript">
	function a(obj){
		obj.innerHTML='2';
		obj.style.backgroundColor="#1ec5e5";
		obj.style.color="#D94A38";
	}
	function b(obj){
		obj.innerHTML='3';
		obj.style.backgroundColor="#D94A38";
		obj.style.width="200px";
	}
</script>
</body>
</html>

3、互换变量值

index2.html

<!DOCTYPE html>
<html>
<head>
	<title>第3题</title>
	<meta charset="utf-8">
</head>
<body>
<p>a=2</p><br>
<p>b=6</p>
<h3>在Console中查看a和b交换的结果</h1>

<script type="text/javascript">
    var a=2;
    var b=6;
    a=b-a;
    b=b-a;
    a=a+b;

	window.onload=function(){

		console.log("a的值为"+a);
		console.log("b的值为"+b);
	}
</script>
</body>
</html>

4、乘法口诀

index3.html

<!DOCTYPE html>
<html>
<head>
	<title>第4题</title>
	<meta charset="utf-8">
</head>
<body>
<div style="color:#D94A38">在Console中查看99乘法表</div>

<script type="text/javascript">
	window.onload=function(){
		for(var i=1;i<10;i++){
			for(var j=1;j<=i;j++){
				var k=i*j;

				console.log(i+"*"+j+"="+k);
			}
		}
	}
</script>
</body>
</html>

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值