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;
}
})
});