I have a problem related to my previous article css, button selection and html tags
Not very good with javascript if any one could offer some insight as to where im going.
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 sp开发者_开发百科an').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. If you download jQuery from their site, you'll see there is the .min.js file and the standard .js file. The fist takes up less space, the second is the readable source. You have the first.
The JavaScript is minified.
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. JavaScript and CSS resources may be minified, preserving their behavior while considerably reducing their file size. Libraries such as JavaScript Optimizer, pack:tag, Minify, Lightweight, CssMin, jsmin-php, MiniME, and ShrinkSafe are capable of such on-the-fly optimizations.
During development you could use the normal jQuery.
From the jQuery page, min is 29k while the normal is 212k.
If you wish to minify your own javascript for production deployment some resources are:
- Jsmin
- Microsoft Jax Minifier
- Online YUI compressor
精彩评论