你是想在jQuery对象上使用DOM方法。你不能把它们混在一起。
$(".work").click(function() {
$("#main_page, #work_page, #contacts_page").hide();
$("#work_page").show();
$("#main-body").css("background-image", "url(resources/fons_mani.jpg)");
});
下面的代码是一个简单的例子。这个例子来自W3Schools。那里有很多关于javascript函数的例子。我建议你去看看。下面的例子可以在这个URL上执行。https:/www.w3schools.comjsreFtryit.asp?filename=tryjsref_onclick
<!DOCTYPE html>
<html>
<body>
<h1>The onclick Event</h1>
<p>The onclick event is used to trigger a function when an element is clicked on.</p>
<p>Click the button to trigger a function that will output "Hello World" in a p element with id="demo".</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
</body>
</html>