I'm kind of new to JQuery. I've been trying to use this 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 i put it in my theme code, it won't work, even though the jsfiddle shows that it works just fine.
If you want to see: http://dialoguetest.tumblr.com/
(where when you click the pink button on the sidebar, the description text changes. But you can only click it once, unlike the jQuery code that enables the button to be clicked a few times for the text change.)
When i tried to use the jQuery, it won't work: http://dialoguetest2.tumblr.com/
Is there something i'm missing? I know that I have to add
<script type="text/javascript">
and end it with
</script>
in order to make it work. But is there something else i'm missing, like using the Google AJAX Libraries API?
If so, how is it possible?