首页 > IT职业 > IT生活 > jquery hello world
jQuery是一个js库,一个js文件,极大地简化了编程,官网链接在这里,有compressed,uncompressed版本,使用时一样.
<html>
<head>
<title>jquery hello world</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(function()
{
$("p").html("hello world");
});
</script>
</head>
<body>
<p></p>
</body>
</html>
jQuery使用时直接从官网引入文件即可,这里用的是3.4.1版本.
$(function())
是
$(document).ready(function(){})
的缩写,这个函数会在DOM加载完成后执行.
$("p")
表示选择页面的所有<p>元素,html()可以设置元素的内容.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1830/viewspace-2825010/ ,如需转载,请注明出处,否则将追究法律责任。