jQuery.parseHTML() 函數


<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="app/js/jquery-2.1.4.js"></script>
		<script type="text/javascript">
			$(function() {
				var str = '<li>1</li><li>2</li><li>3</li><li>4</li><script type="text/javascript">console.log("執行腳本代碼完成");<\/script>';
				var arr0 = jQuery.parseHTML(str, true);
				var arr1 = jQuery.parseHTML(str);
				console.log(arr0);
				console.log(arr0[0]);
				console.log(arr1);
				console.log(arr1[0]);
				$.each(arr0, function(i) {
					$("ul.sb").append(arr0[i]);   
				});
				$.each(arr1, function(i) {
					$("ul.sbs").append(arr1[i]);
				});
			})
		</script>
	</head>

	<body>
		<ul class="sb"></ul>
		<ul class="sbs"></ul>
	</body>

</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM