Are you just reloading the page on clicking the link? I would say you do something like this instead of putting a script tag in your .
HTML
<span id="numberOfCats"></span>
Script
$("a#bar").click(function() {
$('#numberOfCats').text(cat)
});