php生成0~1隨機(jī)小數(shù)的方法(必看)
749
2024-01-10
本文實(shí)例為大家jQuery繼承extend用法,供大家參考,具體內(nèi)容如下
js代碼
//直接基于jQuery的擴(kuò)展,判斷是否為空 $.isBlank = function(obj){ return(typeof(obj)=='undefined'||obj==''||obj==null); } //直接基于jQuery的擴(kuò)展,去除html標(biāo)簽,保留內(nèi)容 $.htmlContent = function(tag){ var reTag = /<(?:.|s)*?>/g; return tag.replace(reTag,""); } //直接基于jQuery的擴(kuò)展(方式二) $.xy = { sayhello:function(){return "hello";}, saybaybay:function(){return "baybay";} }; //jQuery類(lèi)級(jí)別的擴(kuò)展 $.extend({ add:function(a,b){return a+b;}, diff:function(a,b){return a-b} }); //jQuery對(duì)象級(jí)別的擴(kuò)展 $.fn.extend({ getvalue:function(){ return this.val(); } });
html代碼
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base > <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> < <link rel="stylesheet" type="text/css" > --> <script type="text/javascript" src="http://www.gimoo.net/t/1812/jquery-1.7.js"></script> <script type="text/javascript" src="http://www.gimoo.net/t/1812/jquery-1.7.min.js"></script> <script type="text/javascript" src="http://www.gimoo.net/t/1812/my.js"></script> <script type="text/javascript"> $(function(){ var br = $("<br/>"); $(".myspan").append(br); }) </script> </head> <body> <script type="text/javascript"> document.write("判斷是否為空:"+$.isBlank(null)); </script> <span class="myspan"></span> <script type="text/javascript"> document.write("過(guò)濾html標(biāo)簽:"+$.htmlContent("<html><body><a id='a1'>a標(biāo)簽</a><div style='width:100%'>div標(biāo)簽</div>內(nèi)容</body></html>")+"<br/>"); document.write("擴(kuò)展自jQuery類(lèi)的xy的sayhello方法:"+ $.xy.sayhello()+"</br>"); document.write("擴(kuò)展自jQuery類(lèi)的xy的sayhello方法:"+ $.xy.saybaybay()+"</br>"); document.write("基于jQuery類(lèi)的add法:"+ $.add(3,5)+"</br>"); document.write("基于jQuery類(lèi)的diff法:"+ $.diff(5,3)+"</br>"); document.write("基于自jQuery類(lèi)對(duì)象的擴(kuò)展getvalue():"+$("<input type='text' value='str' />").getvalue()+"<br/>"); </script> </body> </html>
輸出
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持綠夏網(wǎng)。
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請(qǐng)用戶(hù)自負(fù)。本站信息來(lái)自網(wǎng)絡(luò)收集整理,版權(quán)爭(zhēng)議與本站無(wú)關(guān)。您必須在下載后的24個(gè)小時(shí)之內(nèi),從您的電腦或手機(jī)中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請(qǐng)支持正版,購(gòu)買(mǎi)注冊(cè),得到更好的正版服務(wù)。我們非常重視版權(quán)問(wèn)題,如有侵權(quán)請(qǐng)郵件[admin@lxwl520.com]與我們聯(lián)系進(jìn)行刪除處理。敬請(qǐng)諒解!