最近在做 Wap网站,在 jQuery Mobile,jqMobi,和 zepto.js 几个框架之间纠结。暂时选用jqMobi,转载一些相关资料备用。
jQMobi 1.0 API 参考
.param() //Serialize a JSON object into KVP for a querystring //序列化一个JSON 对象为键/值对字符串 .parseJSON(string) //Backwards compatability JSON parsing call. Uses the browsers native JSON parser //向后兼容JSON解析调用。使用浏览器原生JSON解析器 .parseXML(string) //Parses a string and returns a XML document version //解析字符串并返回一XML文档的版本 .uuid //Utility function to create a pseudo GUID //用来来创建一个伪GUID .Event(type,props) //Creates a custom event to be used internally //创建一个内部使用的自定义事件
.map(elements,callback)
//Executes callback function on each element
//把当前匹配集合中的每个元素传递给函数,产生包含返回值的新JQMobi 对象。
.each(elements,callback)
//Iterate through elements and execute callback
//对 jQMobi 对象进行迭代,为每个匹配元素执行函数。
.extend(target,{params})
//Extends an object with additional arguments
//给一个对象扩展一个额外的元素
.isArray(data)
//Returns true/false if data is an array
//判断是否为数组,返回值为布尔值。
.isFunction(data)
//Returns true/false if data is a function
//判断是否为函数返回值为布尔值
.isObject(param)
//Returns true/false if param is an object
//判断是否为对象返回为布尔值
.ready(callback)
// Callback executed when DOMContentLoaded happens
//页面加载完成后开始运行
.find(selector)
// Find all chidlren that match the given selector
// 根据已给的选择器查找所有下级元素
.html(['newhtml'])
// Get/Set the elements .innerHTML
// 取得/设置该元素的.innerHTML
.text(['newtext'])
// Get/Set the elements .innerTEXT
//取得/设置该元素的innerText
.css('property',['value'])
//Get/Set the elements css property to value
//获得/设置元素CSS指定属性的值
.empty()
//Sets the elements .innerHTML to an empty string
//设置该元素的.innerHHML一空字符串
.hide()
//Sets the elements display css attribute to "none"
//设置该元素CSS的display属性为"none"
.show()
//Sets the elements display css attribute to "block"
//设置该元素CSS的display属性为"block"
.toggle()
//Togglesthe elements display css attribute
//切换该元素的CSS的display属性(显示/隐藏)
.val(["value"])
//Get/Set the elements value property
//获得该元素的value属性
.attr("attribute",["value"])
//Get/Set the elements attribute
//获得/设置这个元素的属性
.removeAttr("attribute")
//Removes the attribute from the elements
//移除当前元素的该属性
.remove()
//Remove an element from the Dom
//从DOM中移除指定元素
.addClass("className")
//Adds the css class name to the selected elements
//给指定的元素添加该名称的css类
.removeClass("className")
//Removes a css class from the selected lements
//移除指定元素该名称的css类
.hasClass("className",[_element])
//Checks to see if an element has a class
//检查一个元素时候含有该名称的类
.append(element,[insert])
//Appends an element to the selected elements
//向每个匹配的元素内部后置内容。
.prepend(element)
//Prepends an element to the selected elements
//向每个匹配的元素内部前置内容。
.insertBefore(target)
//Inserts a collection before the target (adjacent)
//把匹配的元素插入到另一个指定的元素集合的前面。
.insertAfter(target)
//Inserts a collection after the target (adjacent)
//把匹配的元素插入到另一个指定的元素集合的后面。
.get([index])
//Getraw DOM element based on index. () returns first element
//获得基于. index ()返回的第一个元素
.offset()
//Calculates the first elements offset on the screen
//计算元素在屏幕上的位置
.parent(selector)
//Returns the parent nodes based off selector
//返回该元素的父元素
.children(selector)
//Returns the children of the elements
//返回该元素的后代元素
.siblings(selector)
//Returns the siblings of the elemnts
//获得匹配元素集合中所有元素的同辈元素。
.closest(selector,[context])
//Returns the closest element based off selector
//从元素本身开始,逐级向上级元素匹配,并返回最先匹配的祖先元素。
.filter(selector)
//Filters the elements based off selector
//将匹配元素集合缩减为匹配指定选择器的元素。
.not(selector)
//Return all matches that do NOT match the selector
//返回从匹配元素集合中删除该元素集合。
.data(key,[value])
//Gets/Setsa data-* attribute for the param
//获得/设置一个data-*属性。
.end()
//Rolls back the jqMobi elements when filters were applied
//回滚jqMobi元素当过滤器被应用时
.clone()
//Clones the nodes in the collection
//克隆节点到知道集合
.size()
//Returns the number of elements in a collection
//返回匹配元素数量。
.serialize(grouping)
//Serializes a form into a query string
//将表单内容序列化为字符串。
.jsonP(options)
//Execute a jsonP call, allowing cross domain scripting
//执行JSONP请求,允许跨域
.bind("event",function(){})
//Binds a function to the event listener
//向匹配元素附加一个或更多事件处理器
.unbind("event",[callback])
//Unbinds a function to the event listener
//从匹配元素移除一个被添加的事件处理器
.one("event",callback)
//Bind event to each element - only executes once
//向匹配元素添加事件处理器。每个元素只能触发一次该处理器。
.delegate(selector,"event",callback)
//Delegate an event bassed off selector
//向匹配元素的当前或未来的子元素附加事件处理器
.undelegate(selector,"event",[callback])
//Unbind an event registered through delegate
//从匹配元素移除一个被添加的事件处理器
.on("event",selector,callback) //类似于 .delegate()
.off("event",selector,[callback]) //删除.on()添点的事件处理器
.trigger("event",data)
//Trigger an event and pass in optional data
// 触发事件,并传入一个数据(可选)
.proxy(callback,context)
//Creates a proxy function so the ‘this’ context can be changedin the function
//创建一个代理函数,改变该函数中'this'作用域
$.os.webkit //True if webkit found in the user agent //如果浏览器为webkit核心,返回true $.os.android //True if anroid user agent //如果用户设备为android,返回true $.os.ipad //True if iPad user agent //如果用户设备为ipad,返回true $.os.iphone //True if iPhone user agent //如果用户设备为iphone,返回true $.os.webos //True if WebOS detected //如果用户设备为webos,返回true $.os.touchpad //True if WebOS and Touchpad user agent //如果用户设备为touchpad,返回true $.os.ios //True if iPad or iPhone //如果用户设备为iPad或iPhone,返回true $.os.blackberry //True if Blackberry PlayBook or OS >=6 //如果用户设备为黑莓PlayBook或OS> = 6,返回true
原文:http://www.appmobicn.com/thread-23-1-1.html
擦,屌爆了,最近也在学这个。
@追梦 哎,后来没用它。。改用zepto.js了
请问,后来为什么改用zepto.js???我也在纠结在问题。