In js, the object is obtained according to the element name, the id is obtained, and so on. . .

Obtain:

// get by ID
	var aa = document.getElementById ('bo') ;
	//Get and return a collection according to the element name
	var bb = document.getElementsByTagName('input');
	
	


Change the background color:


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Switch background color</title>

<script>
	
	function changeColor(color)
	{	
		var obt1 = document.getElementById('bo');
	
		//obt1.bgColor= 'blue';
		obt1.bgColor= color;
		
	}
	
	</script>

</head>

<body  bgcolor="red" id="bo" >
	
	<input  type="button" onClick="changeColor('yellow')">
</body>
</html>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325931687&siteId=291194637