$(function(){

    $("div.SubCategoryBox li:gt(7):not(:last)").hide();
$("div.SubCategoryBox ul li").filter(":contains('佳能'),:contains('索尼'),:contains('三星')").addClass("promoted");
$("div.showmore span").click(function(){
if($("div.SubCategoryBox li:gt(7):not(:last)").is(":visible")){
$("div.SubCategoryBox li:gt(7):not(:last)").hide();
$("div.showmore span").text("显示全部品牌");
}else{
$("div.SubCategoryBox li:gt(7):not(:last)").show();
$("div.showmore span").text("精简显示");
}
return false;
}); var $li1 = $("<li title='香蕉'>香蕉</li>");
var $li2 = $("<li title='雪梨'>雪梨</li>"); $("div.three ul").append($li1);
$("div.three ul").append($li2); $("div.four ul li img").mousedown(function(e){
$(this).clone(true).appendTo($("div.clone ul li"));
}) // $("<strong>repalace with fruit</strong>").replaceAll("div.three p"); $("div.three p").attr("title","fruit title-attr"); $("a.tooltip").hover(function(){
var x = 10;
var y = 20;
this.myTitle = this.title;
this.title = "";
var tooltip = "<div id='tooltip'>"+this.myTitle+"</div>";
$("body").append(tooltip);
$("a.tooltip").mousemove(function(e){
$("#tooltip").css({"top":(e.pageY + y)+"px","left":(e.pageX + x)+"px"}).show("fast");
})
},function(){
this.title = this.myTitle;
$("#tooltip").remove();
}) $("a.tooltipimg").hover(function(){
var x = 10;
var y = 20;
this.myTitle = this.title;
this.title = "";
var tooltipimg = "<div id='tooltip'><img src='"+this.href+"' alt='产品预览图'/></div>";
$("body").append(tooltipimg);
$("a.tooltipimg").mousemove(function(e){
$("#tooltip").css({"top":(e.pageY + x)+"px","left":(e.pageX + y)+"px"}).show("fast");
})
},function(){
this.title = this.myTitle;
$("#tooltip").remove();
}) $(":inupt").focus(function(){
$(this).addClass("focus");
}).blur(function(){
$(this).removeClass("focus");
}) $(".bigger").click(function(){
alert($("#comment").width());
})
})
$(function(){

    $(".bigger").click(function(){
var $comment = $("#comment");
if($comment.height() < 500){
if(!$comment.is(":animated")){
$comment.animate({height : "+=50"} , 500);
}
}
})
$(".smaller").click(function(){
var $comment = $("#comment");
if($comment.height() > 50){
$comment.height($comment.height() - 50);
}
})
var $comment = $('#comment');
$('.up').click(function(){
if(!$comment.is(":animated")){
$comment.animate({ scrollTop : "-=50" } , 400);
}
})
$('.down').click(function(){
if(!$comment.is(":animated")){
$comment.animate({ scrollTop : "+=50" } , 400);
}
}); $("#CheckedAll").click(function(){
if(this.checked){
$("[name=items]:checkbox").attr("checked",true);
}else{
$("[name=items]:checkbox").attr("checked",false);
}
})
$("#CheckedNo").click(function(){
$("[name=items]:checkbox").attr("checked",false);
})
$("#CheckedRev").click(function(){
$("[name=items]:checkbox").each(function(){
this.checked = !this.checked;
})
})
$("[name=items]:checkbox").click(function(){
var flag = true;
$("[name=items]:checkbox").each(function(){
if(!this.checked){
flag = false;
}
})
$("#CheckedAll").attr("checked",flag);
}) $("#add").click(function(){
$options = $("#select1 option:selected");
$options.appendTo("#select2");
}) /**
*
*/
/* var page = 4;
var i = 1;
$("span.next").click(function(){
var $parent = $(this).parents("div.v_show");
var $v_show = $parent.find("div.v_content_list");
var $v_content = $parent.find("div.v_content");
var v_width = $v_content.width();
var len = $v_show.find("li").lengh;
var pageCnt = Math.ceil(len/i); if(!$v_show.is(":animated")){
if(page == pageCnt){
$v_show.animate({ left : '0px'}, "slow");
page = 1;
}else{
$v_show.animate({ left : '-='+v_width }, "slow");
page++;
}
}
$parent.find("span").eq((page-1)).addClass("current").siblings().removeClass("current");
}) $("span.prev").click(function(){
var $parent = $(this).parents("div.v_show");
var $v_show = $parent.find("div.v_content_list");
var $v_content = $parent.find("div.v_content");
var v_width = $v_content.width();
var len = $v_show.find("li").lengh;
var pageCnt = Math.ceil(len/i); if(!$v_show.is(":animated")){
alert("v_width: "+v_width+" page: "+page);
if(page == 1){
$v_show.animate({ left : '-='+v_width*(page_count-1)+'0px'}, "slow");
page = pageCnt;
}else{
$v_show.animate({ left : '+='+v_width }, "slow");
page--;
}
}
$parent.find("span").eq((page-1)).addClass("current").siblings().removeClass("current");
})*/ var page = 1;
var i = 4; //每版放4个图片
//向后 按钮
$("span.next").click(function(){ //绑定click事件
var $parent = $(this).parents("div.v_show");//根据当前点击元素获取到父元素
var $v_show = $parent.find("div.v_content_list"); //寻找到“视频内容展示区域”
var $v_content = $parent.find("div.v_content"); //寻找到“视频内容展示区域”外围的DIV元素
var v_width = $v_content.width() ;
var len = $v_show.find("li").length;
var page_count = Math.ceil(len / i) ; //只要不是整数,就往大的方向取最小的整数
if( !$v_show.is(":animated") ){ //判断“视频内容展示区域”是否正在处于动画
if( page == page_count ){ //已经到最后一个版面了,如果再向后,必须跳转到第一个版面。
$v_show.animate({ left : '0px'}, "slow"); //通过改变left值,跳转到第一个版面
page = 1;
}else{
$v_show.animate({ left : '-='+v_width }, "slow"); //通过改变left值,达到每次换一个版面
page++;
}
}
$parent.find("span").eq((page-1)).addClass("current").siblings().removeClass("current");
});
//往前 按钮
$("span.prev").click(function(){
var $parent = $(this).parents("div.v_show");//根据当前点击元素获取到父元素
var $v_show = $parent.find("div.v_content_list"); //寻找到“视频内容展示区域”
var $v_content = $parent.find("div.v_content"); //寻找到“视频内容展示区域”外围的DIV元素
var v_width = $v_content.width();
var len = $v_show.find("li").length;
var page_count = Math.ceil(len / i) ; //只要不是整数,就往大的方向取最小的整数
if( !$v_show.is(":animated") ){ //判断“视频内容展示区域”是否正在处于动画
if( page == 1 ){ //已经到第一个版面了,如果再向前,必须跳转到最后一个版面。
$v_show.animate({ left : '-='+v_width*(page_count-1) }, "slow");
page = page_count;
}else{
$v_show.animate({ left : '+='+v_width }, "slow");
page--;
}
}
$parent.find("span").eq((page-1)).addClass("current").siblings().removeClass("current");
}); })

Jqueryの锋利的jquery练习的更多相关文章

  1. 锋利的jQuery学习总结

    通过对<锋利的jQuery>(第二版)一书的学习,发现此书讲解通俗易懂,是学习jQuery的一本很好的指导书,特作如下总结.此书主要讲解了jQuery的常用操作,包括认识jQuery,jQ ...

  2. [jQuery]《锋利的jQuery》插件部分总结

    /** * <锋利的jQuery>插件部分总结 * * jQuery插件推荐命名:jquery.name.js * * $.fn.extend用于封装对象方法的插件 * $.extend用 ...

  3. 锋利的jQuery读书笔记---选择器

    前段时间入手了锋利的jQuery(第二版),想着加强下自己的js能力,可前段时间一只在熟悉Spring和Hibernate.最近抽时间开始读这本书了,随便也做了些记录. 读书的过程是边看边代码测试,所 ...

  4. 【锋利的jQuery】中全局事件ajaxStart、ajaxStop不执行

    最近一直都在研究[锋利的jQuery],确实是一本好书,受益匪浅.但由于技术发展及版本更新等原因,里面还是有些坑需要踩的. 比如:第六章七节中提到的全局事件ajaxStart.ajaxStop照着案例 ...

  5. 【锋利的jQuery】表单验证插件踩坑

    和前几篇博文提到的一样,由于版本原因,[锋利的jQuery]表单验证插件部分又出现照着敲不出效果的情况. 书中的使用方法: 1. 引入jquery源文件, 2. 引入表单验证插件js文件, 3. 在f ...

  6. 锋利的jQuery幻灯片实例

    //锋利的jQuery幻灯片实例 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  7. 锋利的jQuery(第二版)学习总结

    通过对<锋利的jQuery>(第二版)一书的学习,发现此书讲解通俗易懂,是学习jQuery的一本很好的指导书,特作如下总结. 此书主要讲解了jQuery的常用操作,包括认识jQuery,j ...

  8. jQuery下拉框操作系列$("option:selected",this) &&(锋利的jQuery)

    jQuery下拉框操作系列$("option:selected",this)  &&(锋利的jQuery) <!DOCTYPE html> <ht ...

  9. Jquery全选系列操作(锋利的jQuery)

    Jquery全选系列操作(锋利的jQuery) <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

随机推荐

  1. Android OpenGL ES 开发教程 从入门到精通

    感谢,摘自:http://blog.csdn.net/mapdigit/article/details/7526556 Android OpenGL ES 简明开发教程 Android OpenGL ...

  2. node.js创建服务器报错

    创建nodeTest.js如下: var http = require('http'); http.createServer(function (request, response){ respons ...

  3. Magento Service Temporarily Unavailable解决方法

    插件升级错误或安装失败时 会出现Service Temporarily Unavailable错误,使网站前台后台都无法显示. 在操作完成的情况下,仍然出现这个错误时可以采用以下方法: 1.删除网站站 ...

  4. LightOj1028 - Trailing Zeroes (I)---求因子个数

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1028 题意:给你一个数 n (1<=n<=10^12), 然后我们可以把它 ...

  5. imx6 u-boot.bin 和 u-boot.imx

    有些MFG TOOL烧录工具使用了u-boot.imx,而不是原来的u-boot.bin文件进行烧录. 这两个镜像的区别是,u-boot.bin文件编译后,会在u-boot.bin的开头添加一个大小为 ...

  6. LeetCode Inorder Successor in BST

    原题链接在这里:https://leetcode.com/problems/inorder-successor-in-bst/ Given a binary search tree and a nod ...

  7. jquery 日历插件datepicker格式调整

    <script> $(function() { $("#datepicker").datepicker({ dateFormat: "yy/mm/dd&quo ...

  8. mobiscroll.js 使用

    使用较为详情的参考网址:http://www.lanrenmaku.com/jMobile/2014_1231_1357.html

  9. CLM

    https://github.com/TadasBaltrusaitis/CLM-framework

  10. JavaScript基础总结三部曲之一

      JavaScript是一种基于对象的编程语言,基于对象指的是所有的对象已经由浏览器提供好了,用户直接使用就可以了. 另外,JS是嵌入在HTML语法之中的编程语言. PS:虽然是基于对象的语言,但是 ...