dimanche 26 mars 2017

how to make random my article in another article js

I have

    <div id = "primary">
     <div id= "river" class="story-river" role = "main">
      <article id="post-1"></article>
      <article id="post-2"></article>
      <article id="post-3"></article>
      <article id="post-4"></article>
      <article id="post-5"></article>
     </div>
    </div>

I need create function, it should random add my article to my js code to another article. i try that code, but it doesnt work

itemLength = $('#river article').length; //quantity of .items
randomPlace = Math.floor((Math.random()*articleLength)); 

randomArticle = $('<article />',{
    'class':'randomArticle',
    text: randomPlace
}); 

$('#river article').eq(randomPlace).after(randomDiv); 

can someone tell me what wrong?




Aucun commentaire:

Enregistrer un commentaire