I am trying to use the value of a variable I define using JavaScript for a JQuery function. All of this happens in one .html file. In the body, I create this script:
<script type="text/javascript">
var clicks = 1;
function onClick() {
//Code here to change value of 'clicks'
};
</script>
Later in that file, I use JQuery to pull data from a server when a button called 'previous' is clicked. I use this code:
$('#previous').click(function(){
$('#question').load('/php/getQuestion.php',
{ name: $("clicks").val()} ); //This line is wrong
}
How can I insert the value of 'clicks' into the 'name' field? Thanks
"clicks"actually is supposed to be. 1. If a selector is wrapped in quotes$("tag")it's a<tag>, 2. if a selector is wrapped in quotes and is prtefixed with a period:$(".class")3. If a selector is wrapped in quotes and is prefixed with a hashmark:$('#id').$("clicks")means: *find any<clicks>elements. Of course that element doesn't even exist has the root of your problem.