jquery语法

1向HTML中引入jQuery库
<head>    
<script src="/jquery/jquery-1.11.1.min.js">    
</head>  

如果没有下载到公共文件中,可以直接同过地址引用它。



使用Google的CDN
<head>    
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs    
/jquery/1.8.0/jquery.min.js"></script>    
</head> 



使用Microsoft的CDN
<head>    
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery    
/jquery-1.8.0.min.js"></script>    
</head> 


2.向HTML中引入外部js文件:
<script type="text/javascript" src="{% static 'pos/js/pos.js' %}"></script>


3.js文件中函数的语法:

jQuery 语法

jQuery 语法是为 HTML 元素的选取编制的,可以对元素执行某些操作。
基础语法是:$(selector).action()   
   选择符(selector)//“查询”和“查找” HTML 元素   
    jQuery 的 action() //执行对元素的操作   


所有 jQuery 函数位于一个 document ready 函数中:
$(document).ready(function(){    
    
--- jQuery functions go here ----    
    
});  

$(document).ready(function(){   
   
--- jQuery functions go here ----   
   
}); 

猜你喜欢

转载自lyz8jj0.iteye.com/blog/2386667