Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1.0 MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Move this topic
Forum :
Getting Started
Using jQuery
Using jQuery Plugins
Using jQuery UI
Developing jQuery Core
Developing jQuery Plugins
Developing jQuery UI
QUnit and Testing
About the jQuery Forum
jQuery Conferences
jQuery Mobile
Developing jQuery Mobile
Sub forum :
Move this topic
Cancel
Getting Started
timurca
How to shuffle images?
in
Getting Started
•
11 years ago
i am learning jQuery; last week, with some help from this forum resulted with this code:
http://jsfiddle.net/timur/pArSL/6/
now i want to add additional functionality to it which will shuffle the images.
(on every click, i want to generate and pull random image...)
i googled 'jquery shuffle' and came across with this lovely demo:
http://jsfiddle.net/timur/bAynQ/
can someone help me implement this shuffle logic onto my example.
1
Replies(5)
jakecigar
Re: How to shuffle images?
11 years ago
Rather than shuffling you need a random selection.
Put all the images off screen in the same location. Then randomly select one to appear.
$.fn.randomOne=function(){return this.eq( Math.floor(Math.random()*this.length))};
can be used to pick a single random element from a jQuery of many
$('#listOfImages img').randomOne()
JΛ̊KE
jakecigar
Re: Re: How to shuffle images?
11 years ago
http://jsfiddle.net/gpgzE/5/
JΛ̊KE
Leave a comment on jakecigar's reply
timurca
Re: How to shuffle images?
11 years ago
Thanks Jake.
$.fn.randomOne=function(){return this.eq( Math.floor(Math.random()*this.length))};
What is $.fn ?
Leave a comment on timurca's reply
jakecigar
Re: How to shuffle images?
11 years ago
$.fn.XXXX is how you define a plugin for jQuery.
It becomes a part of jQuery. You can use it like any other method.
$('.foo').eq(0) gives you the first foo, $('.foo').randomOne() gives you a random foo.
JΛ̊KE
Leave a comment on jakecigar's reply
timurca
Re: How to shuffle images?
11 years ago
i see.
thanks.
Leave a comment on timurca's reply
Change topic type
Topic Type :
Discussions
Questions
Ideas
Problems
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to timurca's question
Top
Reply
{"z8461537":[14737000003053206,14737000003050659,14737000003055400],"z2950240":[14737000003050611,14737000003050615,14737000003055338]}
Statistics
5
Replies
5348
Views
1
Followers
Tags
Cancel
random
shuffle
Actions
Permalink