0

Ok this is as basic a jquery coding as you can get.. Why does div id=tx show on load??? I'm testing this on wamp localhost...www folder. Any help?? Is there anything i need to do to save the jquery.js? jquery.js is in the same folder as this page.

<html>
<head>
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#tx')hide();
	});
	</script>
</head>
<body>

<div id="tx">
fjdskla
</div>



</body>
</html>
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by stbuchok
0

1) Move your script from the <head> to the bottom of the <body>. Then you won't need '$(...).ready'. See Souders book High Performance Web Sites if you need more reasons.

2) Don't use jQuery if you don't have to. Hiding/showing a div is simply a matter of switching it's 'display' style between 'block' and 'none'. Write yourself a little function if you'll do this often:

var tx_div = document.getElementById( 'tx' );
hide( tx_div );

function hide( div ) { div.style.display = 'none'; }

3) If you want the div hidden initially, use a stylesheet or an inline style:

<div id="tx" style="display: none">
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.