一些实用的jQuery代码片段

时间:2015-10-24 08:44:55
【文件属性】:
文件名称:一些实用的jQuery代码片段
文件大小:773B
文件格式:TXT
更新时间:2015-10-24 08:44:55
jQuery 1.JQuery得到用户的IP: $.getJSON("http://jsonip.appspot.com?callback=?",function(data){ alert("Your ip:"+data.ip); }); 2.JQuery查看图片的宽度和高度 var theImage = new Image(); theImage.src = $('#imageid').attr("src"); alert("Width:"+theImage.width); alert("Height"+theImage.height); 3.JQuery查找指定字符串 var str = $('*:contains("the string")'); 4js判断浏览器是否启用cookie $(document).ready(function(){ [removed] = "cookieid=1;expires=60"; var result = [removed].indexof("cookieid=") != -1; if(!result){ alert("浏览器未启用cookie"); } }); 5.JQuery检测键盘按键 $(document).ready(function(){ $(this).keypress(function(e){ switch(e.which){ case 13: alert("你按下了回车键"); break; } }) });

网友评论