A rather trivial question, how do I return or pass a value outside the function?
Code below:
function numberOfDivs(){
var numberOfElements = $("#div").children().length; //this count how many divs exist
return numberOfElements;
}
$("#element").click(function(){
numberOfDivs();
console.log(numberOfElements);// here I need to return the number but getting error :(
});
many thanks
numberOfDivs()..clickmethod attaches an event listener to node of idelement, and therefore is asyncnumberOfDivs()) is not async itself (which it isn't).