jQuery面向对象写法规定写法样式规定
1.定义对象
var product = {};
2.对象里面的属性与方法
var product = {init:function(){this.p = 1;this.sort_field = "default";this.sort = "";this.eventBind();},eventBind:function(){var that = this;$(".search_header .search_icon").click( function(){that.search();});$(".sort_box .sort_list li a").click( function(){that.sort_field = $(this).attr("data");if( $(this).find("i").hasClass("high_icon") ){that.sort = "asc"}else{that.sort = "desc"}that.search();});process = true;$( window ).scroll( function() {if( ( ( $(window).height() + $(window).scrollTop() ) > $(document).height() - 20 ) && process ){process = false;that.p += 1;var data = {kw:$(".search_header input[name=kw]").val(),sort_field:this.sort_field,sort:this.sort,p:that.p};$.ajax({url:common_ops.buildMUrl( "/product/search" ),type:'GET',dataType:'json',data:data,success:function( res ){process = true;if( res.code != 200 ){return;}var html = "";for( idx in res.data.data ){var info = res.data.data[ idx ];html += '<li> ' +'<a href="' + common_ops.buildMUrl( "/product/info",{ id:info['id'] } ) + '"> ' +'<i>' +'<img src="'+ info['main_image_url'] +'" style="width: 100%;height: 200px;"/>' +'</i> ' +'<span>'+ info['name'] +'</span> ' +'<b>' +'<label>月销量' + info['month_count'] +'</label>¥' + info['price'] +'' +'</b> </a> ' +'</li>';}$(".probox ul.prolist").append( html );if( !res.data.has_next ){process = false;}}});}});},search:function(){var params = {kw:$(".search_header input[name=kw]").val(),sort_field:this.sort_field,sort:this.sort};window.location.href = common_ops.buildMUrl("/product/index",params);},};
调用:product.init();
3.总结
对象:var obj = {}
对象属性:this.name = "sunxiao";
对象方法调用:this.funcname();
对象方法声明:
funcname:function(){
}
方法之外用逗号隔开
方法之内用分号隔开
jQuery面向对象写法规定写法样式规定相关推荐
- jquery换一批的写法
jquery换一批的写法 $('.huanyipi').on('click',function () { var currentindex=parseInt($(this).attr('current ...
- 用jQuery设置元素的css样式
什么是jQuery ,jQuery 是能用少量的代码写出JavaScript的效果. 学习jQuery 要有一定的JavaScript.CSS.HTML的基础: jQuery 库位于一个 JavaSc ...
- jQuery(三):样式操作
一.DOM操作分类 DOM Core:任何一种支持DOM的编程语言都可以使用它,例如:getElementById(). HTML-DOM:用于处理HTML文档,例如:document.forms. ...
- jQuery Mobile中网格grid样式ui-grid-*
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile 所有class选项 jQuery Mobile中网格grid样式 网格中的列是等宽的(合计是 100%),没有边框.背景.margin ...
- jQuery Mobile中主题theme样式a-z
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile 所有class选项 jQuery Mobile中主题theme样式 Classes 字母 (a-z) 意为样式可以指定 a 到 z.例如 ...
- jQuery Mobile中图标icon样式大全ui-icon-*
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile 所有class选项 jQuery Mobile中图标icon样式大全 //ui-icon-action 动作 (一般用于页面跳转切换) ...
- JSX列表渲染(五)——4种写法:基本写法 遍历写法 map遍历写法(常用-加工处理数组的每一项数据,最后形成一个新的数组) 列表遍历可以直接写到表达式中
JSX列表渲染--4种写法:基本写法 & 遍历写法 & map遍历写法(常用-加工处理数组的每一项数据,最后形成一个新的数组) & 列表遍历可以直接写到表达式中 渲染多个元素 ...
- JQuery字符串文本替换并且加样式
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- jQuery仿微博手机聊天样式代码
jQuery仿微博手机聊天样式代码 下载地址:https://www.yujianni.top/news/comp_artinfo.html?id=57
- Jquery查找父级添加样式
Jquery查找父级添加样式 利用jQuery的parents()函数:试用前请先引入核心jQuery.js HTML结构 首页 样式加在的位置 ,navbar navbar-dropdown bg- ...
最新文章
- python定义一个汽车类_汽车类Python程序
- js判断鼠标位置是否在某个div中
- Centos 7 全网备份Rsync
- Nocalhost: 云原生开发新体验
- Java必刷100题
- ML之xgboost:利用xgboost算法(sklearn+GridSearchCV)训练mushroom蘑菇数据集(22+1,6513+1611)来预测蘑菇是否毒性(二分类预测)
- Java - 对象(object) 具体解释
- 第三章 正态性检验、自相关检验与异方差性检验
- 学习Linux的七点忠告
- image 第二次使用就出错是怎么回事_第二次上机报告-RNA-seq (HISAT - SAMtools- StringTie - ballgown)amp;amp;Gene-Assembly
- 合抱之木,生于毫末。九层之台,起于累土。千里之行,始于足下
- STM32L4时钟系统(转载)
- HTML2——图像、超链接
- 武汉理工大学计算机考研考纲,2018年武汉理工大学825流体力学考试大纲
- 计算机考试的时候有文字解析吗,计算机考试解析.doc
- Vue项目的常见报错问题解决
- android nfc扇区加密,nfc读取加密扇区
- Bootstrap 自定义表单
- MacBook Pro M1 Parallels Desktop 安装 Ubuntu
- kaggle实战:海星赛复盘