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(){
document.cookie = "cookieid=1;expires=60";
var result = document.cookie.indexof("cookieid=") != -1;
if(!result){
alert("浏览器未启用cookie");
}
});
5.JQuery检测键盘按键
$(document).ready(function(){
$(this).keypress(function(e){
switch(e.which){
case 13:
alert("你按下了回车键");
break;
}
})
});
本文介绍了使用jQuery实现获取用户IP地址、查看图片尺寸、查找字符串以及检测键盘按键的基本方法。
4529

被折叠的 条评论
为什么被折叠?



