Hi,

Im working with Javascript for the first time and am having a problem setting a javascript var on a jQuery onclick function. Can anyone see why the var in document.write(num_cow); is not being set?

Thanks

Code:
<script>var num_cow;
</script>

<div class="green_button_1_class_1 ">ADD TO YOUR FARM</div>

<script>		
	
			document.write(num_cow);
	
		</script>

<script>
$(document).ready(function() {

$('.green_button_1_class_1').click(function() {
			
			// increment the Cow variable
			num_cow = num_cow + 1;
			
    		return false;
  		});
}
</script>