--- title: jQuery slug: Glossary/jQuery translation_of: Glossary/jQuery ---
jQuery 是專精於簡化 {{Glossary("DOM")}}、{{Glossary("AJAX")}}、與 {{Glossary("Event")}} 操作的 {{Glossary("JavaScript")}} {{Glossary("函式庫")}}。
jQuery 用 $(selector).action() 格式,指派元素到指定的事件。詳細來說, $(selector) 會呼叫 jQuery 選取 selector 元素,並指派它到稱作 .action() 事件的 {{Glossary("API")}}。
$(document).ready(function(){
alert("Hello World!");
$("#blackBox").hide();
});
上面這段 jQuery 程式碼,會執行與這段原生 JavaScript 程式碼相同的事情:
window.onload = function() {
alert("Hello World!");
document.getElementById("blackBox").style.display = "none";
};
或這段:
window.addEventListener("load", () => {
alert("Hello World!");
document.getElementById("blackBox").style.display = "none";
});