Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the next element of an array with Jquery onclick
    primarykey
    data
    text
    <p>Hi all i am trying to change the html of an object from an array of htmls. But i am having problem iterating properly. I managed to make it work once EDIT After a few complains about the clarity of my question I will rephrase it. I have a div panel called .trpanel and a button called #trigger2 (it is a next button). Then I have a series of divs with texts that contain translations. I want when I press the button (called next) to cycle through the translations one by one on the trpanel. </p> <pre><code>var ltranslation = []; ltranslation[0] = $("#translation-en-1").html(); ltranslation[1] = $("#translation-ur-en").html(); ltranslation[2] = $("#translation-fr-en").html(); ltranslation[3] = $("#translation-it-en").html(); ltranslation[4] = $("#translation-sp-en").html(); ltranslation[5] = $("#translation-po-en").html(); ltranslation[6] = $("#translation-fr-en").html(); ltranslation[7] = $("#translation-de-en").html(); var l= ltranslation; $("#trigger2").off('click').on('click',function(){ for (var i = 0; i &lt;= ltranslation.length; i++){ if (i==7){i=0;} $(".trpanel").html.ltranslation[i]; or ???//replace().ltranslation[]+i??? the code throws errors } }); </code></pre> <p>I am quite new to Javascript and i am getting a bit confused with the types of objects and arrays and loops. I managed once to add the htmls but without replacing them ... so they all came one after the other. The i tried to change the code and it hasn't worked since. Any help will be greatly appreciated. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload