简体   繁体   English

选项卡选择的jquery问题

[英]jquery problem on tab selection

I have a problem related to my previous article css, button selection and html tags 我有一个与我以前的文章css,按钮选择和html标签相关的问题

Not very good with javascript if any one could offer some insight as to where im going. 使用javascript不是很好,如果任何人可以提供一些洞察我去哪里。

Thanks to any one who can help 感谢任何能提供帮助的人

$(function() {

$('input.field').
focus(function() {
    if(this.title==this.value) {
        this.value = '';
    }
}).
blur(function(){
    if(this.value=='') {
        this.value = this.title;
    }
});

var currentPage = 1;
$('#slider .buttons span').live('click', function() {
    var timeout = setTimeout(function() {$("img").trigger("slidermove")}, 300);
    var fragments_count = $(this).parents('#slider:eq(0)').find('.fragment').length;
    var fragmet_width = $(this).parents('#slider:eq(0)').find('.fragment').width();
    var perPage = 1;
    var numPages = Math.ceil(fragments_count/perPage);
    var stepMove = fragmet_width*perPage;
    var container = $(this).parents('#slider:eq(0)').find('.content');
    var firstPosition = 0;
    var lastPosition = -((numPages-1)*stepMove);

    if ($(this).hasClass('next')) {
        currentPage ++;
        if (currentPage > numPages) {
            currentPage = 1;
            container.animate({'left': firstPosition});
            return;
        };
        container.animate({'left': -((currentPage - 1)*stepMove)});
    };
    if ($(this).hasClass('prev')) {
        currentPage --;
        if (currentPage < 1) {
            currentPage = numPages;
            container.animate({'left': lastPosition});
            return;
        };
        container.animate({'left': -((currentPage-1)*stepMove)});
    };
});});

在此输入图像描述

The jQuery code you have in your description is the minimized version. 您的描述中的jQuery代码是最小化版本。 If you download jQuery from their site, you'll see there is the .min.js file and the standard .js file. 如果从他们的站点下载jQuery,您将看到.min.js文件和标准.js文件。 The fist takes up less space, the second is the readable source. 拳头占用的空间较少,第二个是可读源。 You have the first. 你有第一个。

The JavaScript is minified . JavaScript被缩小了

Components and libraries for Web applications and websites have been developed to optimize file requests and quicken page load times by reducing the size of various files. 已经开发了用于Web应用程序和网站的组件和库,以通过减小各种文件的大小来优化文件请求并加快页面加载时间。 JavaScript and CSS resources may be minified, preserving their behavior while considerably reducing their file size. JavaScript和CSS资源可能会缩小,保留其行为,同时大大减少文件大小。 Libraries such as JavaScript Optimizer, pack:tag, Minify, Lightweight, CssMin, jsmin-php, MiniME, and ShrinkSafe are capable of such on-the-fly optimizations. JavaScript Optimizer,pack:tag,Minify,Lightweight,CssMin,jsmin-php,MiniME和ShrinkSafe等库可以进行这种即时优化。

During development you could use the normal jQuery . 在开发过程中,您可以使用普通的jQuery

From the jQuery page, min is 29k while the normal is 212k. 从jQuery页面,min是29k而正常是212k。

If you wish to minify your own javascript for production deployment some resources are: 如果您希望缩小自己的javascript以进行生产部署,则有些资源是:

  1. Jsmin Jsmin
  2. Microsoft Jax Minifier Microsoft Jax Minifier
  3. Online YUI compressor 在线YUI压缩机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM