JQuery :: How To Make An Unfinished Loop
Aug 13, 2010
i am a beginner with jquery and im wondering how i can make an unfinished loop? i have some code written and i how can i make a loop which is running all the time since document ready.
for example i would change a background color for #block or slideUp this element. this would be also perfect if i could delay this actions and stop the loop on mouseover but this are the question for the future :)
[Code]...
View 1 Replies
ADVERTISEMENT
May 27, 2011
I'm trying to make a list of tweets fade in and out progressively down the list. I'm pretty new to javascript and jquery, so I might be missing out on some basics.
1. How do I make the while loop infinite and loop around itself, because I'd like the tweets to loop around when it reaches the last tweet. I tried adding the if statement to make it go back to 0 but it hangs my page when I include it.
2. How do I make the loop not run altogether at once? I've tried queue() and putting in delay(4000) right before the .eq(n) so that it delays 4000ms before selecting the next tweet, but I'm trying to find a more elegant solution to it as the timing might be offset infinitely if there are changes in the timings.
var $j = jQuery.noConflict();
$j(document).ready(function() {
var tweet = $j('#twitter-3 .tweets li').length;
var n = 0;
while (n <= tweet) {
$j('#twitter-3 .tweets li').eq(n).delay(500).fadeIn(1000).delay(2000).fadeOut(500);
n++;
//if (n == tweet) {
// n = 0;
//};
};});
View 5 Replies
View Related
Feb 5, 2010
Code JavaScript:
var listItems = "";
$.each(msg.d, function(index, value) {
listItems += "<li><a href='#' class='" + value.Availability + "' title='" + value.Time + "' >" + value.Time + " - " + value.Availability + "</a></li>"
});
var teeTimeLinks = $(listItems + 'li');
$.each(teeTimeLinks, function() {
var link = $(this).find('a');
link.bind('click', function(event) {
event.preventDefault(); //stop the link from going to href
TeeTimeSelected(this);
});
});
The above code works. BUT, msg.d returns 80 objects. We then loop through it and make our list items. AND then we loop through it again and apply the click event. How can this be optimized into one loop?
View 18 Replies
View Related
Nov 25, 2011
Im using a slideshow on my website but it stops when he displayed all 10 images but i wanna make it loop.
Here is my script:
Quote:
View 1 Replies
View Related
Jul 8, 2009
How can you make a multiplication table using For loop? I've been trying to make one, but still.. :(
Anyway, if you have one.. May I see how you do it? ( codes )
View 4 Replies
View Related
Jul 17, 2009
Why wont my for loop work it wont alert the var images1....
<script type="text/javascript">
for(i=1;i<6;i++){
images[i] = "no"+i+".jpg";
[code]...
View 2 Replies
View Related
Feb 10, 2011
I have this loop:
for (var j = 0; j < gmarkers.length; j++) {
gmarkers[j].hide();
elabels[j].hide();
map.closeInfoWindow();
[Code]....
which was useful for passing the p variable when it was just one number.
but now I need to get that number every time j gets set (I understand that the j gets overwritten each time the loop goes through).
What would be ideal is if p could become an array, the contents of which match the values that j has passed though during the loop cycle.
I thought var p = new Array (j); minght do the trick, but obviously not...
View 4 Replies
View Related
Jun 8, 2009
I have a pretty simple function set up to pull XML data into my page, but there's a couple things wrong with it. I'm REALLY new to J Script and really trying my best to learn, but for some reason I'm not yet adept at googling the right results :rolleyes:At the very bottom you can see the data from the first XML entry, so it seems the function itself is working fine, but it's not looping coorectly to access all the data.Also, I want to pull it into the "shows" div of the page, but can't figure out how to put it there (seriously, I am very new with JS). The code below is not working, but the live site has it added to the body, which does show the one entry.Here's the XML function, the XML data and the HTML markup:
Shows function -
function loaddates()
{
var xmlData = document.getElementById("tourdates");
var newDates = xmlData.getElementsByTagName("dates");
[code]...
View 4 Replies
View Related
Aug 30, 2010
I am working on a site and in the process borrowed some js from some one to get dropdown menus to work, but after a while got reports from people who tested my site of some problems and decided to verify all my code, and i have fixed most bugs but the one listed in the title.
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
[code]....
View 7 Replies
View Related
Aug 28, 2009
how can I make some functions repeat them after they have triggered?Like, I want that this will repeat if triggered:
$('.class').animate({ 'opacity' : 1 }, 1000);
$('.class').animate({ 'opacity' : 0 }, 2000);
View 2 Replies
View Related
Jul 29, 2011
I have the code below, how could it be modified to loop over and over and reload the xml file each time. Flow would be: load xml, run thruogh code to display each xml node one at a time, when reach last node, start all over, reloading xml file,
[Code]...
View 2 Replies
View Related
Jan 22, 2011
I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together.
What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array.
What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created.
Here is the test object:
test = [
{
"name" : "Menu 1",
"url" : "menu1.html",
"submenu" : [
[Code].....
'Menu 2' and 'Menu 3' don't show up! I'm sure it's something small that I'm overlooking.
View 2 Replies
View Related
Aug 4, 2011
I'm looking to send a loop variable (i) to a function inside the loop, but I can't seem to get it to use the value I want, it keeps making it a reference of i and therefore the function is always called using the last value of i rather than the one it was set with.
So if i have 5 Tabs then Tab 1, when clicked, should call DefaultTabClick(0) and so on rather than always using 4 for any of the tabs.
View 2 Replies
View Related
Mar 6, 2011
As you can see from the code and the output, it will attempt to write to the browser how many moves, but only '0'.
function rollDie()
{
return Math.floor(Math.random() * 6) + 1;
}
/*
*searches for a number in a number array.
*
*function takes two arguments[CODE]...
View 5 Replies
View Related
Dec 8, 2011
I have several classes named 'ratings_colored'. They all contain a number from 1 to 10. If the number is below 5.5, the number should become red. If not it should become green.
The code below works, but if the first .ratings_colored is higher than 5.5 it will make ALL the classes green. Even the numbers below 5.5! I tried using the 'this' but it didn't work either.
$(document).ready(function () {
View 2 Replies
View Related
Nov 12, 2010
I am doing some studying and we was to create a small loop using either the for loop, while loop or do while loop. I chose to do the for loop because it was easier to understand, but I want to know how to do the same using the while loop. Here is the for loop I have, but I cant figure out how to change to while loop.
for (var i = 0; i < 5; ++i)
{
for (var j = i; j < 5; ++j)
{
[Code]....
How do you make the same using a while loop?
View 2 Replies
View Related
Jul 5, 2010
it wont loop,as long as you enter something in the name field it will submit. also how do i stop from submitting if all fields are not filled out?
function checkForm(form)
{
var len = form.elements.length;[code]....
View 3 Replies
View Related
Jan 27, 2010
My objective is to make a map that lets the user click the map to make a pin and write a description. Like this [URL]
View 13 Replies
View Related
Dec 2, 2009
How Can i take this to make a default empty value and force users to make a decision?
<select id="preservetitletest"
name="titletest"
dojoType="$testWidget"
style="width:50%;font-family:Courier;"
[Code]....
View 1 Replies
View Related
Sep 28, 2011
Currently i am working on ajax slideshow in which slides come from xml document. each slide contain slide having source code for example
as " <li><a
href
=
"#pix1"
><img
[Code].....
View 1 Replies
View Related
Apr 28, 2009
I am trying to loop through my top level nav i.e <ul> <li> and then apply that class name to teh sub level menu of that particular top level. So essentially the clas name on the top <li> wil be applied to its sub level items. Here is my code, which isn't working at the moment:
$(document).ready(function(){
var pageID = $('body').attr('id');
var uniquePageID
uniquePageID =$("#site-nav ul li",this).attr('id');
[Code].....
View 3 Replies
View Related
Dec 28, 2011
How to loop this code for the array I have in php? I need this to work for all associates we have on our contact page. This checks their AIM status.
View 5 Replies
View Related
Nov 6, 2011
I am currently working on a data input website and have a form which is excel style in layout with 10 rows to input the same fields 10 times. I can get the datepicker in each field but when selected it only populates the first field. I know I must put some sort of value or something in the datepicker class but not sure how it works. Any help on this would be great I have attached the code below:
[Code]...
View 3 Replies
View Related
Jul 21, 2010
I have while loop, where something is defined via ID, I called it pin_click.
So of course there are a few entries.
And I have the following Code:
Somehow, this Code only works for the first element, I get out of the while loop. The other elements of the while loop ( which have the same Button ) are just doing nothing, even no action in Firebug.
View 6 Replies
View Related
May 5, 2010
I'm trying my first bit of jQuery code but am familiar with Java programming. I'm trying to create a function that loads a div with an image in it, which will fade in and then after 4 seconds move onto the next image. I want it to create an infinite loop but it doesn't work.
<script type="text/javascript">
$(document).ready(function ()
{
[code]...
View 4 Replies
View Related
Sep 26, 2011
I have a collection of links on a page with unique ID's in the form of:
Code:
<a id="tag_t1"
<a id="tag_t2"
[code]....
View 5 Replies
View Related