javascript - JQuery not working on Tumblr? -
i'm kind of new jquery. i've been trying use jquery http://jsfiddle.net/54pp2/2/ ,
<input id="click" type="button" value="click" /> <label id="test">test</label>
$(document).ready(function () { var textarray = []; textarray[0] = 'test 1'; textarray[1] = 'test 2'; textarray[2] = 'test 3'; textarray[3] = 'test 4'; var idx = 0; $('input#click').on('click', function() { idx++; var newidx = idx % textarray.length; $('label#test').text(textarray[newidx]); }); });
but when put in theme code, won't work, though jsfiddle shows works fine.
if want see: http://dialoguetest.tumblr.com/
(where when click pink button on sidebar, description text changes. can click once, unlike jquery code enables button clicked few times text change.)
when tried use jquery, won't work: http://dialoguetest2.tumblr.com/
is there i'm missing? know have add
<script type="text/javascript">
and end
</script>
in order make work. there else i'm missing, using google ajax libraries api?
if so, how possible?
to make work in html page need place script reference jquery along js code (in dom ready handler) in head
. this:
<!doctype html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript> $(document).ready(function () { var textarray = []; textarray[0] = 'test 1'; textarray[1] = 'test 2'; textarray[2] = 'test 3'; textarray[3] = 'test 4'; var idx = 0; $('input#click').on('click', function() { idx++; var newidx = idx % textarray.length; $('label#test').text(textarray[newidx]); }); }); </script> </head> <body> <input id="click" type="button" value="click" /> <label id="test">test</label> </body> </html>
Comments
Post a Comment