html - Javascript loop refuses to do a function -


My Javascript changes the internal HTML, but refuses to add delays for it. My goal is to create a menu that is a Moves the list item after the second, but it only works for the first two list items. I have used the internal HTML so that I can see if it touches them. I'm not sure that is not working. I did X [0], X [1] .. and so on and it worked. Also another question: D, how can I select all the elements with a tag name in a fixed ID?

JS:

  var x = document getElementsByTagName ("LI"); Var delay = 0; (I = 0; i & lt; = x.length; i ++) for {x [i] .style.padding = "0 0 px 20px"; X [i]. Style Transcision = "1s" + Delay + "S! Important" x [i] .innerHTML = "Replace"; Delay + = "0.1"; }  

HTML:

  & lt; Header class = "mainHeader" & gt; & Lt; NAV & gt; & Lt; Ul id = "mainNav" & gt; & Lt; Li id = "search" & gt; & Lt; Img src = "img.png" & gt; Input  
itemprop = "text">

  delay = delay < 0.1; Without using it, "" because it creates a string, it will not behave as a number and the number of 0.1 will be increased, it starts to become 00.10.10.10.1 etc. Will be done.  

Answer

How can I select all the elements with a tag name in a fixed ID?

Use jQuery:

  $ ('tagname # some_id')  

or

  $ ('tagname [id = "some_id"]')  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -