- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘Other’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I used the jquery code here (https://css-tricks.com/random-ad-positions/) but when I try to link the images, the link doesn’t follow the image; it stays at the original spot it was linked on the page. So it basically links the wrong image. Someone please help me, I’m desperate right now.
Messed up. See below.
You can see my page in action here: http://www.bluegrasscostsavers.com/html-testing.html
Here’s my jq code:
(function($){
$.fn.shuffle = function() {
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
this.each(function(i){
$(this).replaceWith($(shuffled));
});
return $(shuffled);
};
})(jQuery);
$(function() {
$("#ad-group-one img").shuffle();
});
_________________________________________________________________
Here’s my HTML code:
Seriously, I have to have this fixed ASAP and I really need some help, if anyone has any help for me or knows another way to successfully randomize images w/ link let me know!!!!!!
Bump. Still desperately need help :
Why don’t you try using the PHP method? For me, it’s much better (and the only one I can help you with because I am useless when it comes to jQuery).
How can I do it on a site that has to end in .html? Can I create a separate PHP file and call it through the .html page? Sorry, I probably sound pretty clueless…