程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> (二)菜鳥學jQuery(高手請繞路)

(二)菜鳥學jQuery(高手請繞路)

編輯:ASP技巧

今天學習jQuery的核心函數.

jQuery(exPRession,[context])
這個函數接收一個包含 CSS 選擇器的字符串,然後用這個字符串去匹配一組元素。
jQuery 的核心功能都是通過這個函數實現的。 jQuery中的一切都基於這個函數,或者說都是在以某種方式使用這個函數。這個函數最基本的用法就是向它傳遞一個表達式(通常由 CSS 選擇器組成),然後根據這個表達式來查找所有匹配的元素。

默認情況下, 如果沒有指定context參數,$()將在當前的 Html 文檔中查找 DOM 元素;如果指定了 context 參數,如一個 DOM 元素集或 jQuery 對象,那就會在這個 context 中查找。(摘自jQuery API)

 

費話不多說直接看例子:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html XMLns="Hello'>http://www.w3.org/1999/xhtml"><head><title>Hello World jQuery</title><style>.showtext{ background:#999999; color:#990000; font-weight:800; width:auto; height:40px;}.showtext3{ background:#666; color:#0000FF; font-weight:600; width:auto; height:30px;}</style><script type="text/javascript" src="jquery-1.3.2-vsdoc2.JS"></script></head><body><div id="divMsg" >無心測試JQuery!</div><input id="btnShow" type="button" value="顯示" />    <input id="btnHide" type="button" value="隱藏" /><br />    <input id="btnChange" type="button" value="修改內容為Hello World jQuery!" /> <input id="btnChange2" type="button" value="修改內容為 無心測試JQuery!!" /> <script type="text/Javascript">$("#btnShow").bind("click",function(event){$("#divMsg").show("fast")}); $("#btnHide").bind("click",function(event){$("#divMsg").hide("slow")});  $("#btnChange").bind("click", function(event) { $("#divMsg").html("Hello World jQuery!"); });  $("#btnChange2").bind("click",function(event){$("#divMsg").Html("無心測試JQuery!!");});</script> <h4>順便介紹下本人QQ高級群67221760(炒股群) !</h4> <div><p>今天上班遲到啦!</p></div><div></div><div><p>不過也要按時寫博客</p></div><div><p>扣工資也無所謂啦</p></div><span>9999999999999999999</span><span class="showtext2">3333333333333333333</span><script language="Javascript">$( function() {  //匹配所有的span元素,  var showText=$("span");  //對所有span元素添加class屬性  showText.addClass("showtext");  //匹配所有div中含有p的元素  var selectDiv=$("div p");  //showtext的內容賦值  showText.text("93路公交車不來我有啥辦法呢");  //對selectdiv元素添加class屬性  selectDiv.addClass("showtext3");  //通過CSS類名選擇元素  var selectByClass=$(".showtext2");  selectByClass.text("我先聲明我起床很早的。");   })</script></body></Html></P> <div class="qcxs_ie_he"></div> </div> <div class="akevx_own"><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4480737146802772" crossorigin="anonymous"></script> <!-- aspphp 2 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4480737146802772" data-ad-slot="9530743267" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div> <div class="akevx_mj"></div> <div class="qcxs_ie_he"></div> <ol class="qmsbvx_hsb ovv_hex"> <li>上一頁:<a class='LinkPrevArticle' href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108132.html' >個人電腦搭建版本控制平台的最簡單方法</a></li><li>下一頁:<a class='LinkNextArticle' href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108134.html' >個泛型的小例子 Linq查詢解決Combox綁定問題</a></li> </ol> </div> </div> <div class="qirnxbd bg1 mt20"> <div class="jdbsbav"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/' target="_blank">ASP技巧</a> <div class="jdbsbav_hx"></div> </div> <div class="qirnxbd_rbx"> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107780.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011311591279_S.jpg' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107780.html' target="_blank"><strong>ASP.NET中的Code Behind技術(3)</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107780.html' target="_blank"><p> 2).創建虛擬目錄  首先在c:\InetPub\WWWR</p></a> </div> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108375.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011312072492_S.jpg' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108375.html' target="_blank"><strong>Windows 2003上傳文件不能超過200k解決方法</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108375.html' target="_blank"><p>   問題:無法上傳較大的文件“Request 對象 錯誤 </p></a> </div> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107798.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011311593297_S.gif' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107798.html' target="_blank"><strong>十天學會ASP之第一天</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107798.html' target="_blank"><p> 學習目的:安裝調試ASP的環境,寫出第一個HELLO WO</p></a> </div> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108420.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011312075323_S.jpg' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108420.html' target="_blank"><strong>Windows 7常用快捷鍵整理 - 任務欄按鍵篇</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108420.html' target="_blank"><p> 對於鍵盤流而言,自然是恨不得所有操作都能通過鍵盤快捷鍵來完</p></a> </div> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107978.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011312014227.jpg' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107978.html' target="_blank"><strong>網頁編碼轉換器的使用教程</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107978.html' target="_blank"><p> 在進行ASP程序開發的時候,有時候會遇到多種語言版本的網站</p></a> </div> <div class="oiendx"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107772.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011311590678_S.gif' width='100' height='70' border='0'></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107772.html' target="_blank"><strong>NET移植案例學習:建造Web站點(7)</strong></a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107772.html' target="_blank"><p>  圖5 客戶端的驗證邏輯FormSubmitTe</p></a> </div> <div class="qcxs_ie_he"></div> </div> </div> </div> <div class="eccsgxsg mt20"> <div class="xiangbgbax bg1"> <div class="ejmnxbns">相關文章</div> <ul class="pdirbvx lbhevs ovv_hex lbhevs_40"> <li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/java/javazh/201704/231599.html' target="_self">菜鳥對spring aop 最基本的理解。以及應用,springaop</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/gengduo/delphi/201701/220722.html' target="_self">DELPHI版傳奇引擎學習菜鳥篇(applem2)-03,applem2-03</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/gengduo/delphi/201701/220721.html' target="_self">DELPHI版傳奇引擎學習菜鳥篇(applem2)-02,applem2-02</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/gengduo/delphi/201701/220719.html' target="_self">DELPHI版傳奇引擎學習菜鳥篇(applem2)-01,applem2-01</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/216357.html' target="_self">菜鳥都能理解的0-1背包問題的空間優化</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/215587.html' target="_self">給編程菜鳥——起跑時的堅持</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/214341.html' target="_self">菜鳥思維思考 extern關鍵字</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/212133.html' target="_self">FOSU菜鳥新篇章Tempter of the Bone</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/211301.html' target="_self">菜鳥學習Hibernate——配置Hibernate環境</a></li><li><a class='LinkArticleCorrelative' href='https://www.aspphp.online/bianchen/cyuyan/cjj/cjjrm/201701/208499.html' target="_self">菜鳥入門之lua與c++相互調用(包含多個demo)</a></li> </ul> </div> <div class="akevx_oin"></div> <div class="nenxnxb bg1 mt20"> <div class="enxvsfgg"> <div class="enxvsfgg_1">閱讀排行榜</div> </div> <div class="pdirbvx lbhevs ovv_hex"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108773.html' target="_blank">將ASP代碼移植為VB COM組件-3</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108471.html' target="_blank">利用ASP+JMAIL進行郵件群發的新思路</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108859.html' target="_blank">如何用ASP編寫網站統計系統二</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108030.html' target="_blank">ASP程序實現網站在線人數統計的方法</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108760.html' target="_blank">用asp生成wml</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108015.html' target="_blank">asp過濾非法字符函數</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108091.html' target="_blank">asp.net的優化 服務器控件背後友好的Html和JS</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107753.html' target="_blank">手把手教你使用Java來編寫ASP組件(2)</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108022.html' target="_blank">asp中禁用FileSystemObject組件方法</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108772.html' target="_blank">將ASP代碼移植為VB COM組件-2</a> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/108205.html' target="_blank">ASP正則匹配URL的正確性</a> </div> </div> <div class="wuwbxbxsv mt20"> <div class="hrbbxsxsf">熱門圖文</div> <div class="sbnexs"> <a href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/201701/107778.html' target="_blank"><img class='pic1' src='https://www.aspphp.online/bianchen/UploadFiles_4619/201701/2017011311591060_S.gif' width='230' height='170' border='0'></a> </div> <div class="pdirbvx lbhevs ovv_hex lbhevs_80"> <a href='https://www.aspphp.online/bianchen/wangye/php/gyphp/201701/145591.html' target="_blank">php常用命令</a> <a href='https://www.aspphp.online/bianchen/dnet/gydnet/201701/14253.html' target="_blank">WCF示例(17) - 安全(Security)</a> <a href='https://www.aspphp.online/bianchen/java/gyjava/201701/131911.html' target="_blank">Java日期操作實例</a> <a href='https://www.aspphp.online/bianchen/dnet/aspnet/gyaspnet/201701/18891.html' target="_blank">ASP.NET彈出一個對話框</a> <a href='https://www.aspphp.online/bianchen/wangye/php/gyphp/201701/161059.html' target="_blank">推薦文章系統(一)</a> <a href='https://www.aspphp.online/bianchen/cyuyan/gycyy/201701/80773.html' target="_blank">C#3.0新體驗(二)(1)</a> <a href='https://www.aspphp.online/bianchen/wangye/php/gyphp/201701/145778.html' target="_blank">使用php語句將數據庫*.sql文件導入數據庫</a> <a href='https://www.aspphp.online/bianchen/cyuyan/cjj/gycjj/201701/4809.html' target="_blank">BZOJ 2791 Poi2012 Rendezvous 倍增LCA</a> </div> </div> <div class="eqibneb bg1 mt20"> <div class="lkebxsg">欄目導航</div> <div class="eqibneb_1 ovv_hex"> <a class='childclass' href='https://www.aspphp.online/bianchen/wangye/asp/asprm/' target="_self">ASP入門教程</a><a class='childclass' href='https://www.aspphp.online/bianchen/wangye/asp/aspjc/' target="_self">ASP基礎知識</a><a class='childclass' href='https://www.aspphp.online/bianchen/wangye/asp/gyasp/' target="_self">關於ASP編程</a><a class='childclass' href='https://www.aspphp.online/bianchen/wangye/asp/aspjq/' target="_self">ASP技巧</a> </div> </div> </div> <div class="qcxs_ie_he"></div> </div> </div> <div class="qcxs_ie_he"></div> <div class="ebrxbsbf">Copyright © <a href="https://www.aspphp.online/" target="_blank" title="程式師世界">程式師世界</a> All Rights Reserved </div> </body> </html>