I have an image array and need to resize the images smaller by 35%. Here is the javascript:
//set up an array of comic images
var imgs = [
'http://ift.tt/1DOeGsA',
'http://ift.tt/1yab5ma',
'http://ift.tt/1acm2Z3',
'http://ift.tt/1yab5mc',
'http://ift.tt/1acm2Z5',
'http://ift.tt/1yab5me'],
// initialize current to 0
current = 0;
function next() {
current++;
if (current > imgs.length) current = 0;
return imgs[current];
}
function previous() {
current--;
if (current < imgs.length) current = 0;
return imgs[current];
}
// define the first image in terms of a jquery object
var comic = $('<img/>').attr('src', imgs[0]);
// append to DOM
$('#comics').append(comic);
$('#prev').on('click', function () {
comic.attr('src', prev());
});
$('#next').on('click', function () {
comic.attr('src', next());
});
On top of the jquery though is a simple html code for the buttons but I think the function prev not working is because I am doing something wrong in the jquery itself. I haven't done programming since for more than 5 years and I am pretty rusty. Any help would be awesome.
JSFiddle code:http://ift.tt/1CotA2Y Website code is being used at: monroyart.net
Aucun commentaire:
Enregistrer un commentaire