javascript - Creating dynamic HTML hyperlinks -


using list of genes have created in python script, trying create clickable links each gene in list. using flask framework accomplish , able access genes in list {{genes}} variable. able see list when view page source, when try add each gene body of dom javascript function don't see anything. know doing wrong?

<!doctype html> <html>     <head>         <h1>genes<h1>         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">         </script>      </head>     <script type ="text/javascript">     function showgenes(){          var name = "";         (gene in {{genes}}) {             var name = document.createelement('a');             var text = document.createtextnode(name);             name.appendchild(text);             document.body.appendchild(name);          }  }     </script>  <body onload="showgenes()">  </body>  </html> 

in case {{genes}} javascript array, need replace loop following way (just remember, javascript, not python, cannot use - in loop easily):

$.each({{genes}}, function(index, value){      $('body').append($('<a></a>').text(value));  }) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -