Conversion between jQuery object and Dom object

<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="../../js/jquery-1.8.3.js" ></script>
		<script>
			function JSWrite(){
				//document.getElementById("span1").innerHTML="Beautiful!";
				var spanEle = document.getElementById("span1");
                       //The Dom object is converted into a jQ object just by enclosing it with $()! !
				$(spanEle).html("Beautiful!");
			}
			
			$(function(){
				/*document.getElementById("btn1").onclick = function(){
					document.getElementById("span1").innerHTML="Handsome!";
				}*/
				$("#btn1").click(function(){
					//The first way to convert jQ objects into DOM objects
					//$("#span1")[0].innerHTML="Hehe!";
					//The second way to convert JQ objects into DOM objects
					$("#span1").get(0).innerHTML="Hehe!";
				});
				
			});
		</script>
	</head>
	<body>
		<input type="button" value="JS写入" onclick="JSWrite()"/>
		<input type="button" value="JQ写入" id="btn1"/><br /><br />
		<span id="span1">sssss</span>
	</body>
</html>

Guess you like

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