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?
Yes, you are writing the num_cow variable to the page on page load, at the time of page load, num_cow is undefined (your top line), it isn’t truly defined until the div is clicked.