首页 > 代码库 > javascript入门(一)

javascript入门(一)

高手就可以直接跳过了,刚开始学习javascript,从零开始, 记录一点一滴,不断提高。菜鸟的不断成长。

下面就写上几个简单的JS  入门代码吧。高手就不要BS了

<!DOCTYPE html>
<html>

	<body>
		<script>
		function changeImage(){
			element=document.getElementById("myimage")
			if(element.src.match("bulbon")){
				element.src=http://www.mamicode.com/"i/eg_bulboff.gif";>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>Jscript例子1</h1>
	<p id="demo">
	hello world.welcome to here.
	</p>
<script type="text/javascript">
		function myf(){
		x=document.getElementById("demo");
		x.innerHTML="你好,PPKER。欢迎来到JS";
		}
</script>
	<input type="button" onclick="myf()" value=http://www.mamicode.com/"点击">>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>改变样式</h1>
	<p id="demo">
	德玛上单,不给就送啊!
	</p>
	<script type="text/javascript">
		function myf(){
			x=document.getElementById("demo");
			x.style.color="red";
		}
	</script>
	<input type="button" onclick="myf()" value=http://www.mamicode.com/"点击">>
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" /></head>
<body>
<input id="demo" type="text">
<script type="text/javascript">
function myf()
{
var x=document.getElementById("demo").value;
if(x==""||isNaN(x))
	{
	alert("姐,请输入数字");
	}else{
		alert("OK");
	}
}
</script>

<button type="button" onclick="myf()">点击这里</button>

</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function  myf(){
		document.getElementById("demo").innerHTML="~~~上MISS了,嘿嘿嘿";
	}
</script>
</head>
<body>
	<p id="demo">努克萨斯</p>
	<button type="button" onclick="myf()">点击</button>
</body>
</html>
高手就不要BS了,都是从菜鸟开始的。别总是在想如何学好,坚持下去吧。无他,唯孰而已。





javascript入门(一)