jquery 返回顶部、图片比例缩小、验证元素是否存在
2013-09-05 20:23
351 查看
jquery 返回顶部、图片比例缩小、验证元素是否存在
返回顶部代码
$(document).ready(function() {
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetoffset = $target.offset().top;
$('html,body').animate( { scrolltop: targetoffset }, 900);
return false;
}
}
});
});
图片比例缩小
代码如下:
$(document).ready(function(){
var ywidth = 450;//初始最大宽度
$(”img”).each(function(){
if($(this).width() > ywidth) {
$(this).width(ywidth);
$(this).mouseo教程ver(function(){
$(this).css教程(”cursor”,”hand”);
});
$(this).click(function(){
window.location.href = $(this).attr(”src”);
});
}
});
});jquery 验证元素是否存在
$(document).ready(function() {
if ($('#id').length) {
// do something
}
});
返回顶部代码
$(document).ready(function() {
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetoffset = $target.offset().top;
$('html,body').animate( { scrolltop: targetoffset }, 900);
return false;
}
}
});
});
图片比例缩小
代码如下:
$(document).ready(function(){
var ywidth = 450;//初始最大宽度
$(”img”).each(function(){
if($(this).width() > ywidth) {
$(this).width(ywidth);
$(this).mouseo教程ver(function(){
$(this).css教程(”cursor”,”hand”);
});
$(this).click(function(){
window.location.href = $(this).attr(”src”);
});
}
});
});jquery 验证元素是否存在
$(document).ready(function() {
if ($('#id').length) {
// do something
}
});
相关文章推荐
- appium 学习各种小功能总结--功能有《滑动图片、保存截图、验证元素是否存在、》---新手总结(大牛勿喷,新手互相交流)
- jquery 验证元素是否存在
- jQuery 让图片等比例缩小,让所有图片都等比例缩小
- jquery判断一个元素是否存在
- (2010-08-22)利用jQuery实现的Ajax 验证用户名是否存在
- 艾伟_转载:利用jQuery实现的Ajax 验证用户名是否存在
- asp.net AJAX 验证用户名是否存在 -Jquery(转)
- JQuery判断元素是否存在
- jquery判断页面中是否存在某元素
- 利用jQuery.validate异步验证用户名是否存在
- jquery判断页面元素是否存在
- 利用jQuery实现的Ajax 验证用户名是否存在
- struts2+jquery验证注册用户是否存在
- jquery判断元素的子元素是否存在
- jQuery判断元素是否存在的可靠方法
- 利用jQuery实现的Ajax 验证用户名是否存在
- jQuery 检查某个元素在页面上是否存在实例代码
- jQuery异步验证用户名是否存在示例代码
- jQuery:如何验证某个元素是否为空