6.12.2022

document.getElementById("demo").innerHTML在jquery中即$('#demo')[0].innerHTML

 1. 首先在HTML head加上:

 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

2. document.getElementById("demo")可用$('#demo')[0]取代,例如:

document.getElementById("demo").innerHTML = "Hello JavaScript!";

可寫成:

$("#demo")[0].innerHTML = "Hello JavaScript!";