Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2013, 05:19 PM   PM User | #1
cfabrice
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cfabrice is an unknown quantity at this point
loop in javascript

In order to integrate the scrollto javascript in a wordpress theme,
I need to dynamically generate the following script:
Code:
$(function(){
					// Prepare
					var links = [
						{
							id: 'scrollto1',
							text: 'some text'
						},
						{
							id: 'scrollto2',
							text: 'some text',
						},
						{
							id: 'scrollto3',
							text: 'sometext',
						}
					];

					// Fetch
					var $links = $('#scrollto-links');

					// Append Links
					$.each(links,function(i,link){
						$('<a>'+link.text+'</a>').click(function(){
							$('#'+link.id).ScrollTo(link.options);
						}).appendTo($links);
					});
				});
And this for a X numbers that i will get through counting some posts with a php function I guess.
I tried the following code without success:
Code:
$(function(){
					// Prepare
			for		(var i=0;i<6;i++)
			{
			links = [
						{
							id: 'scrollto',
							text: 'Scroll to #scrollto'+[i]
						}
					];
}
					// Fetch
					var $links = $('#scrollto-links');

					// Append Links
					$.each(links,function(i,link){
						$('<a>'+link.text+'</a>').click(function(){
							$('#'+link.id).ScrollTo(link.options);
						}).appendTo($links);
					});
				});
Any help is welcome ;-)
Thanks,
f

Last edited by VIPStephan; 02-02-2013 at 09:13 PM.. Reason: corrected code BB tags
cfabrice is offline   Reply With Quote
Reply

Bookmarks

Tags
jquery, loop

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:06 PM.


Advertisement
Log in to turn off these ads.