<!DOCTYPE html>
<html>
<head>
<script type="text/JavaScript" src="jquery.min.js"></script>
</head>
<body>
<div> Old Content </div>
<script>
$(document).ready(function(){
$("button").click(hidefunction());
});
function hidefunction(){
// Hide all divs on the page
$("div").hide();
}
</script>
<div> New Content. If you click on me, I will disappear.This jquery code doesn't work if we takeout document.ready code from function. The Function "hidefunction" works by itself. Without clicking the button the "div" hides. </div>
<button> Hide all div</button>
</body>
</html>
问问题
74 次