王新阳

wangxinyang

jQuery cxSelect 联动下拉菜单

中文:http://code.ciaoca.com/jquery/cxSelect/

https://github.com/ciaoca/cxSelect

jQuery Wookmark 瀑布流布局

中文:http://code.ciaoca.com/jquery/wookmark/demo/

http://www.wookmark.com/jquery-plugin

https://github.com/GBKS/Wookmark-jQuery

js生成二维码、条形码

QRCode.js 生成二维码

中文文档:http://code.ciaoca.com/javascript/qrcode/

http://github.com/davidshimjs/qrcodejs


jquery-barcode.js 生成条形码

http://www.cnblogs.com/yjmyzz/p/jquery-barcode.html

http://barcode-coder.com/en/barcode-jquery-plugin-201.html

<script>
var barcodeSettings = {
	output:'css',	//可选值:css/bmp/svg/canvas(后三种在IE9以下无效)
	bgColor: '#ffffff',	//背景色
	color: '#000000',	//前景色
	barWidth: 2,	//每单元宽度
	barHeight: 50,	//条码高度,对二维条码无效
	moduleSize: 5,	//仅类型为datamatrix(二维条码)时有效
	posX: 5,	//output=canvas时有效
	posY: 5,	//output=canvas时有效
	addQuietZone: 1	//仅类型为datamatrix(二维条码)时有效
},
type='code39',	//码制,可选值:ean8/ean1/upc/std25/int25/code11/code39/code93/code128/codebar/msi/datamatrix
str='0123456789';	//条码内容
$("#barcode").html("").show().barcode(str, type, barcodeSettings);
</script>

Exif.js 读取图像的元数据

中文文档:http://code.ciaoca.com/javascript/exif-js/

https://github.com/jseidelin/exif-js

Array.sort()

var arrDemo = new Array();
arrDemo[0] = 10;
arrDemo[1] = 50;
arrDemo[2] = 51;
arrDemo[3] = 100;
arrDemo.sort(); //调用sort方法后,数组本身会被改变,即影响原数组
alert(arrDemo); //10,100,50,51 默认情况下sort方法是按ascii字母顺序排序的,而非我们认为是按数字大小排序
arrDemo.sort(function(a,b){return a-b}); //从小到大排序
alert(arrDemo); //10,50,51,100
arrDemo.sort(function(a,b){return b-a}); //从大到小排序
alert(arrDemo); //100,51,50,10

1、数组调用sort方法后,会影响本身(而非生成新数组)
2、sort()方法默认是按字符来排序的,所以在对数字型数组排序时,不可想当然的以为会按数字大小排序!
3、要改变默认的sort行为(即按字符排序),可以自行指定排序规则函数(如本例所示)

jquery mobile动态添加元素

动态添加li

$('ul').append('<li>内容</li>').listview('refresh');

动态添加ul

$('div').append('<ul data-role="listview"><li>内容</li></ul>').trigger('create');

动态添加option

$('select').append('<option value="1">内容</option>').selectmenu('refresh');
jquery mobile 多个页面间切换时,遇到页面内容不变的情况,首先检查data-role="page"的id,确保id不同。在不禁用ajax的情况下,id相同,jqm不会发起新的请求,而是直接调用缓存。

jquery mobile 开启页面缩放

在jquery mobile中页面缩放默认是关闭的。要开始缩放功能,只需在header或footer标签添加data-disable-page-zoom=false属性即可。

<div data-role="header|footer" data-disable-page-zoom="false">

注:开启缩放时,data-role=header|footer中都不能有data-position="fixed"属性。

jquery mobile转跳页面时闪动问题的解决

<a href="url" data-transiation="slide">文本</a>
slide转跳时当前页面滚动条会跳到页面顶端
slidefade不会出现这种问题
以下CSS解决进入目标页面后闪一下的问题,效果还不错
.ui-page {
	backface-visibility:hidden;
	-webkit-backface-visibility:hidden;	/* Chrome 和 Safari */
	-moz-backface-visibility:hidden; 	/* Firefox */
	-ms-backface-visibility:hidden; 	/* Internet Explorer */
}

jquery mobile 禁用ajax

局部禁用ajax,只需在a标签上添加 data-ajax="false" 或 rel="external" 站外链接)

全局禁止ajax,需要在jquery.js之后、jquery.mobile-1.4.5.js引用之前添加:

<script>$(document).ready(function(){jQuery.mobile.ajaxEnabled = false;});</script>

2024-05-14 星期二 农历四月初七