javascript - Advance internal array pointer to next record to fill jquery function to use insertAfter -


I am a jquery newbie and I am trying to create a jquery function with the information supplied with php. I'm sorting the div to display in the order of value with the insert object. (What's an easy / easy approach?) My point is that I can not advance the pointer to advance on the next record to fill my foreclosure loop.

My PHP:

  $ my_array = array ("peter" => "100", "LOIS =>" 75 

My jquery: > $ (Document) .ready (function () {var peter = $ ("# peterDIV"); var lois = $ ("# loisDIV"); var brian = $ ("# brianDIV"); & lt ;? php foreach ($ my_array as $ x = & gt; $ x_value) {echo strotler ($ x) ".interval (". strtolower ($ x) ");";}}? "gt;}); Result:

  peter.insertAfter (peter); lois.insertAfter (Lois); Brian.insertAfter (brian);   

I have the next () and array_shift () but I think my syntax is off.

Edit

Desired Results

  lois.insertAfter (peter); Brian.insertAfter (lois);   

I want to jquery displa y in the order based on the values ​​obtained in a SQL database from a query div.

Your solution:

  $ My_array = array ("PETER" =>, "100", "LOIS" => "75", "BRIAN" => "25"); arsort ($ my_array); $ Previous_key = ''; Check the first repetition of foreign currency ($ my_array $ key = & gt; $ value) {// loop - if this key is set and leave the rest of the loop ($ previous_key === '') {$ previous_key = $ key; to continue; } // Similar to your solution, but sets the second key as the echo string ($ key) ".insertAfter (". Strtolower ($ previous_key). "); \ N"; // current key $ previous_key = update the last key with key; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -