Random button that reload a div or script not page using jquery or javascript -


i'm new @ , need random button on page show new line of information in div every time click on random button. wondering if there on 800 lines possible put in outside file txt or html.

here got far , doesn't work , i'm getting confuse... please help

<script type="text/javascript" src="jquery-2.2.0.js"></script> <script type="text/javascript">     $(document).ready(function(){         $('#text').hide();          $('a#random').click(function(){             $('#text').toggle();         })          function rndtext() {             var rannum= math.floor(math.random()*textarray.length);             document.getelementbyid('#text').innerhtml=textarray[rannum];         }         var textarray = [          "hello",          "how you",          "good bye"             ];         $("#text").load()     }) </script>  <body>     <div id="text">line show</div>     <a href="#" id="random">random</a> </body> 

uh. pretty this:

$('a#random').click(function(){     $('#text').toggle();     rndtext();  //you're }); 

although point out rndtext() uses document.getelementbyid when use $("#text") instead. (there's .html() method write value instead of .innerhtml property).

document.getelementbyid not working because used "#text" instead of "text", jquery uses css selectors, getelementbyid not.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -