代码如下:jQuery五角星评分插件#rating_cont { background: #1E1D1C url(images/rating_background.jpg) top left no-repeat; border: 1px solid #F9BA0D; width: 140px; height: 23px; text-align: left; margin-left: 6px;} #rating_on { background: url(images/rating_onbackground.jpg) top left no-repeat; width: 0px; height: 21px; position: relative; z-index: 50; top: -21px; }#rated { display: none; width: 138px;...
代码如下:(function($) { $.fn.tablepage = function(oObj, dCountOfPage, fresh_id) { var dPageIndex = 1; var dNowIndex = 1; var sPageStr = ""; var dCount = 0; var oSource = $(this); var sNoSelColor = "#CCCCCC"; var sSelColor = "black"; var sFontColor = "white"; var nowIndex = 1;change_page_content();function change_page_content() { // 取得資料筆數 dCount = oSource.children().children().l...
代码如下: "http://www.w3.org/TR/html4/strict.dtd"> jQuery背景墙聚光灯效果代码 $(window).load(function(){ var spotlight = { // the opacity of the "transparent" images - change it if you like opacity : 0.2,/*the vars bellow are for width and height of the images so we can make the same size */ imgWidth : $('.spotlightWrapper ul li').find('img').width(), imgHeight : $('.spot...
代码如下:$.ajax({ url : deliveryWarrant/update.do, data : $(#myform).serialize(), type : "POST", success : function(data) { var res = eval(( + data + )); if (res && res.success == true) { alert(res.message); location.href="/form.php?godownWarrant.code="+$("#myform input[name=godownWarrant\\.code]").val(); } else { alert(res.message); ...
代码如下:/** * 格式化日期 * @param {Object} ms 表示指定日期与 1970 年 1 月 1 日午夜间全球标准时间的毫秒数 * @return year-month-date hh:mm */ Util.parseToDate = function(ms){ var date = (new Date(parseInt(ms))); return formatDate(date,"yyyy-MM-dd mm:hh"); }; /** * 格式化日期 * * yyyy-------年 * MM---------月 * dd---------日 * hh---------时 * mm-----...
代码如下: /** 日期比较 **/ function compareDate(strDate1,strDate2) { var date1 = new Date(strDate1.replace(/\-/g, "\/")); var date2 = new Date(strDate2.replace(/\-/g, "\/")); return date1-date2; } /** 比较 **/ function doCompare(){ var strDate1 = document.getElementById("strDate1").value; var strDate2 = document.getElementById("strDate2").value; var result = compar...
应为要有交互,选择了Js来实现,也算是 结对编程 的初试吧。 我将显示部分用html 写好,点击的按钮触发事件函数是check();代码如下:function onCheck(){ var Year = document.getElementById("year").value; //获取文本框的“年” var theYear =Year * 1; //转换为number类型 //alert(theYear); // 获取月值 var month = document.getElementById("month"); var index1=month.selectedIndex; var theMonth = month.options[index1...
对于jQuery对象,只是把each方法简单的进行了委托:把jQuery对象作为第一个参数传递给jQuery的each方法.换句话说:jQuery提供的each方法是对参数一提供的对象的中所有的子元素逐一进行方法调用。而jQuery对象提供的each方法则是对jQuery内部的子元素进行逐个调用。代码如下:jQuery.prototype.each=function( fn, args ) { return jQuery.each( this, fn, args ); } 让我们看一下jQuery提供的each方法的具体实现,jQuery.each(obj,...
代码如下: //javascript Object: ajax Object//Created By RexLeefunction Ajax(url,data){ this.url=url; this.data=data; this.browser=(function(){ if(navigator.userAgent.indexOf("MSIE")>0) { return "MSIE";//IE浏览器 }else{ return "other";//其他 }})();};Ajax.prototype={ get:function(){ var result; var xmlhttp; if(this.browser==M...
代码很简单,直接上代码了,大家可以复制下面的代码保存成HTML文件运行看效果 代码如下:function Change(HourSurplus,MinuteSurplus,SecondSurplus){ SecondSurplus = SecondSurplus - 1; if (SecondSurplus { SecondSurplus=60+SecondSurplus; MinuteSurplus=MinuteSurplus-1; } if (MinuteSurplus { MinuteSurplus=60+MinuteSurplus; HourSurplus=HourSurplus-1; } document.getElementById("asd").innerHTML=""+...
但是,我们在使用中就会发现问题,这里的数组排序方法并不是按照我们想像中的数字大小来排序的,而是按照字符串测试结果改变原先的数据。这并不是我们想要的。 那么如何才可以得到我们想要的按照我们思维中的数字大小来排序呢。我们可以自己编写一个函数来实现。 代码如下:var values = [0, 1, 5, 10, 15];// asc升序函数function compareAsc(value1, value2) { if (value1 > value2) { return 1; } else if (value1 ...
JavaScript只有函数作用域;每个函数都有个作用域链直达window对象。 变量的查找由内而外层层查找,找到即止。 同时不仅可以查找使用,甚至可以改变外部变量。代码如下:var color = "blue";function changeColor() { var anotherColor = "red"; function swapColors() { var tempColor = anotherColor; anotherColor = color; color = tempColor; } swapColors();}changeColor();console.log(col...
yepnope.js的一个典型实例:yepnope({test : Modernizr.geolocation,yep : 'normal.js',nope : ['polyfill.js', 'wrapper.js'] });此实例表示如果Modernizr.geolocation为真的时候加载normal.js,为假则加载polyfill.js及wrapper.js。 yepnope完整语法:yepnope([{test : /* boolean(ish) 输入条件 */,yep : /* array (of strings) | string - 条件为真时加载的资源 */,nope : /* array (of strings) | string - 条件为假时加载的...
checkbox操作 1. 全选、全不选 2.打印所有的选中项目// 全选、全不选function docChkBoxChange(){var isChecked = jQuery('#docChkBoxTop').attr('checked');// 设置以下所有的 checkBox 列表jQuery("input[name=docChkBox]").each(function(){this.checked = isChecked;});}//end function// 打印所有的选中项目function printChoose(){var isChecked = jQuery('#docChkBoxTop').attr('checked');// 设置以下所有的 checkBox 列表...
效果(新版Firefox中测试):代码:Google Map Google Maps JavaScript API v3(参考文档):https://developers.google.com/maps/documentation/javascript/basics 百度地图API的参考文档:http://developer.baidu.com/map/jsmobile.htm