$(document).ready(function(){ var bcount = 0; if (bcount !== 0) { $("span.num-sub").text(bcount); } });