jquery基础语法
2015-11-22 09:21
561 查看
<span style="font-size:18px;">jQuery 语法实例 $(this).hide() jQuery hide() 函数,隐藏当前的 HTML 元素。 <html> <head> <script type="text/javascript"src="../jquery/jquery.js"tppabs="http://www.w3school.com.cn/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $(this).hide(); }); }); </script> </head> <body> <button type="button">Clickme</button> </body> </html> $("#test").hide() jQuery hide() 函数,隐藏 id="test" 的元素。 <html> <head> <script type="text/javascript"src="../jquery/jquery.js"tppabs="http://www.w3school.com.cn/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("#test").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p id="test">This is anotherparagraph.</p> <button type="button">Clickme</button> </body> </html> $("p").hide() jQuery hide() 函数,隐藏所有 <p> 元素。 <html> <head> <script type="text/javascript"src="../jquery/jquery.js" tppabs="http://www.w3school.com.cn/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button type="button">Clickme</button> </body> </html> $(".test").hide() jQuery hide() 函数,隐藏所有 class="test" 的元素。 <html> <head> <script type="text/javascript"src="../jquery/jquery.js"tppabs="http://www.w3school.com.cn/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $(".test").hide(); }); }); </script> </head> <body> <h2 class="test">This is aheading</h2> <p class="test">This is aparagraph.</p> <p>This is another paragraph.</p> <button type="button">Clickme</button> </body> </html> jQuery 语法 jQuery 语法是为 HTML 元素的选取编制,可以对元素执行某些操作。 基础语法是:$(selector).action() 美元符号定义 jQuery 选择符(selector)“查询”和“查找” HTML 元素 jQuery action() 执行对元素的操作 实例 $(this).hide() - 隐藏当前元素 $("p").hide() - 隐藏所有段落 $("p.test").hide() - 隐藏所有 class="test" 的段落 $("#test").hide() - 隐藏所有 id="test" 的元素 提示:jQuery 使用的语法是 XPath 与 CSS 选择器语法的组合。在本教程接下来的章节,您将学习到更多有关选择器的语法。 文档就绪函数 您也许已经注意到在我们的实例中的所有 jQuery 函数位于一个 document ready 函数中: $(document).ready(function(){ --- jQuery functions go here ---- });</span>
相关文章推荐
- JQuery零碎知识点归纳
- JQuery实现简单的图片滑动切换特效
- jquery 换肤功能
- jQuery 小技巧
- 小议jQuery插件开发
- 在Jquery实现Ajax和JS实现Ajax的方法
- 小议jQuery插件开发
- 国内的Jquery CDN免费服务
- jQuery 效果使用
- jQuery之防止冒泡事件
- HTML+CSS+JavaScript+JQuery+JSP学习笔记
- 2 jquery选择器
- jquery each跳出循环的问题
- 1 认识Jquery
- jQuery
- JQuery EasyUI内Combobox的onChange事件
- jquery监听按键
- 经典收藏 50个jQuery Mobile开发技巧集萃
- jQury下的自动补全及插件jquery.autocomplete.min.js的使用
- 用Jquery写一个点击展示下拉菜单,再点击收起来