Time of Update: 2013-10-22
代碼中用到了jQuery,傳入的參數是jQuery選擇的input對象.原理:先用正則匹配,再提取時分秒,看其是否在正常的範圍內。複製代碼 代碼如下:/** * 檢測時間是否符合格式 * @param {Object} timeTextBox */function checkTime(timeTextBox){ var time = timeTextBox.val(); var regTime
Time of Update: 2013-10-22
Jquery的api中提供了對元素應用disabled和readonly屬性的方法,在這裡記錄下。如下: 1.readonly 複製代碼 代碼如下: $('input').attr("readonly","readonly")//將input元素設定為readonly $('input').removeAttr("readonly");//去除input元素的readonly屬性
Time of Update: 2013-10-22
document.title //設定文檔標題等價於HTML的title標籤 document.bgColor //設定頁面背景色 document.fgColor //設定前景色彩(文本顏色) document.linkColor //未點擊過的連結顏色 document.alinkColor //啟用連結(焦點在此連結上)的顏色 document.vlinkColor //已點擊過的連結顏色 document.URL //設定URL屬性從而在同一視窗開啟另一網頁
Time of Update: 2013-10-22
複製代碼 代碼如下: $(function(){ $(".child_tab tr:last-child").find("td").css({borderBottom:'none'}) //獲得文字框對象 var t = $(".amount-input"); //數量增加操作 $(".amount-up").click(function(e){ var c1=parseInt($(this).prev().val()); $(this).prev().val(c1+1);
Time of Update: 2013-10-22
複製代碼 代碼如下: //排序數組 function SortBy(field, reverse, primer) { reverse = (reverse) ? -1 : 1; return function (a, b) { a = a[field]; b = b[field]; if (typeof (primer) != 'undefined') { a = primer(a); b = primer(b); } if (a < b) return reverse * -1;
Time of Update: 2013-10-22
複製代碼 代碼如下: <html> <head> <script type="text/javascript" src="jquery-1.5.1.min.js"></script> <script type="text/javascript"> $(function(){ $("#chk").bind({ click: function(){ if($(this).attr("checked")){
Time of Update: 2013-10-22
下面對使用JavaScript實現頁面定時跳轉(也稱倒計時跳轉)做一下總結,各種定時跳轉代碼記錄如下: (1)使用 setTimeout 函數實現定時跳轉(如下代碼要寫在body地區內) 複製代碼 代碼如下: <script type="text/javascript"> // 3秒鐘之後跳轉到指定的頁面 setTimeout(window.location.href = "http://3aj.cn/javascript/19.html", 3); </script>
Time of Update: 2013-10-22
將一個字串(可以是中文,在產生二維碼圖片之前將中文轉碼)產生二維碼圖片,如果想要帶log的二維碼,可以在產生後的二維碼中間部位自己添加一個小log,log圖片不要太大,不然就掃描不出內容了。 複製代碼 代碼如下: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="js/jquery-1.8.3.js"
Time of Update: 2013-10-22
複製代碼 代碼如下: <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script> $(function(){ $("#getAtr").click(function(){ $str=''; $str+="<tr align='center'>"; $str+="<td><input type='text'
Time of Update: 2013-10-22
jquery實現滑鼠點擊div外的地方div視窗隱藏消失的複製代碼 代碼如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta
Time of Update: 2013-10-22
首先我們應該知道,在jquery中,$(貨幣符號)就是jquery的別名,也就是說使用$和使用jquery是一樣的,在很多時候我們命名空間時,正是因為這個$而產生的衝突的發生。比如說:$('#xmlas')和JQuery('#xmlas') 雖然在寫法上不同,但在實際上卻是完全等同的。要想解決這個衝突,其實最簡單的方法就是使用不同的名稱來命名,或者讓執行代碼認為是不同的命名空間即可。一、 jQuery庫在其他庫之前置入,直接使用jQuery(callback)方法如:複製代碼 代碼如下:<
Time of Update: 2013-10-22
複製代碼 代碼如下: <html> <head> <style> .mydiv1 {height:250px;width:250px;border:#909090 1px solid;} .mydiv2 { width:250px;height:250;border:#909090 1px solid;background:#fff;color:#333;
Time of Update: 2013-10-22
複製代碼 代碼如下: //ECMAScript 5 Function.prototype.bind函數相容處理 (function(){ if ( !Function.prototype.bind ) { //function(){}.bind Function.prototype.bind = function ( o, /*參數列表*/ ) { var self = this, boundArgs = Array.prototype.slice.call(arguments, 0);
Time of Update: 2013-10-22
複製代碼 代碼如下: function getBasePath(){ var obj=window.location; var contextPath=obj.pathname.split("/")[1]; var basePath=obj.protocol+"//"+obj.host+"/"+contextPath; return basePath; } javascript對象包含 1.window javascript的頂層對象 2.navigator 用戶端瀏覽器的資訊
Time of Update: 2013-10-22
setAdminTabs.js代碼中添加如下: 複製代碼 代碼如下: $("#adminTabs li").mouseover(function(){$(this).addClass("selectedTab")}); 始終不起作用,原因如下: 複製代碼 代碼如下: .selectedTab{background-color:White; border-bottom:1px} 定義兩個屬性,在admin.css的檔案中存在,如下: 複製代碼 代碼如下: #adminTabs ul li{
Time of Update: 2013-10-22
複製代碼 代碼如下: jQuery.prototype.test=function(){ this.css("color","#99");//這裡的this是jquery對象,而不是dom對象 alert(this[0]);//這裡的this[0]指的是dom節點對象 } 複製代碼 代碼如下: $("body").click(function(){ $(this).test(); $(this).test().html(this.nodeName).hide(10000); })
Time of Update: 2013-10-22
如果您還有別的要求,想繼續使用原先的$(),同時還需要與別的類庫不衝突的話,還有兩種解決方案 其一: 複製代碼 代碼如下: jQuery.noConflict(); jQuery(function($) { $("p").click(function() //在函數內繼續可以使用jquery類庫的$()方法 { alert($(this).text()); }) }) var JsCOM_cr = $("cr"); // 在函數外面,照樣可以使用JsCOM.js的$()方法 其二: 複製代碼
Time of Update: 2013-10-22
複製代碼 代碼如下: <tr> <th>是否映射:</th> <td> <input type="radio" name="sfys" class="radio" id="yes" value="1"/><label for="yes">是</label> <input type="radio" name="sfys" class="radio" id="no"
Time of Update: 2013-10-22
當輸入url地址後網頁出現:Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "E:\wamp\www\cms\system/templates/index.html" on line 79 "$("#job").load("./system/templates/touch/test.php",{catid:3})
Time of Update: 2013-10-22
問題描述:jquery的字元集是utf-8,load方法載入完GB2312編碼靜態頁面後,出現中文亂碼。 a.php 複製代碼 代碼如下: <script language="javascript" type="text/javascript"> $(function(){ $("#zz").click(function(){ $("#job").load("b.php"); }) }) </script> <a