you need to wrap it with a finished document block. this prevents code from running until the page is fully loaded.
<script type="text/javascript"> $(function() { // do something on document ready $("ul.tabs li.label").hide(); $("#tab-set > div").hide(); $("#tab-set > div").eq(0).show(); $("ul.tabs a").click( function() { $("ul.tabs a.selected").removeClass('selected'); $("#tab-set > div").hide(); $(""+$(this).attr("href")).show(); $(this).addClass('selected'); return false; } ); $("#toggle-label").click( function() { $(".tabs li.label").toggle(); return false; }); }); </script>
source share