今天遇到了jquery没有起作用。有以下几个方面的错误:
- 没有引进有效的jquery。
想要使用js或者jQuery,必须引进js。引进方法:本地或者互联网。
本地引进说明如下:
head头部增加script的标签地址,如下:
<script type="text/javascript" src="/sta/jquery-3.1.1.min.js"></script>
如果没有js的包,在html控制台中会提示:
Failed to load resource: the server responded with a status of 404 (Not Found)
- jQuery格式不对
id没有带#
无提示。 - 没有加function
直接写的函数,没有写function,jQuery不知道这是function,导致错误。如下:
$("#addS").click(
function(){
$("#shadeID").removeClass("hide");
$("#modeID").removeClass("hide");
}
)