我想改變兩個div的字體大小,當我點擊一個特定的按鈕,但按鈕點擊沒有響應,請幫助。 我在一個選擇器中使用兩個div ID。 也請讓我知道錯誤在哪裏,下面是我的代碼。無法增加點擊一個按鈕的字體大小
<html>
<head>
<title>
Example 2
</title>
<style>
body
{
margin:10px 2em;
}
.switcher
{
float:right;
margin:10px;
background-color:#ddd;
border: 1px solid #000;
padding : 10px;
font-size:0.9em;
}
.large
{
font-size:2em;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function{
$('#switcher-large').on('click',function(){
$('#header, #chapter-preface').addClass('large');
});
});
</script>
</head>
<body>
<div id="container">
<div id="switcher" class="switcher">
<h3>Style Switcher</h3>
<button id="switcher-default">
Default
</button>
<button id="switcher-narrow">
Narrow Column
</button>
<button id="switcher-large">
Large Print
</button>
</div>
<div id="header">
<h2>A Christmas Carol</h2>
<h2 class="subtitle">In Prose, Being a Ghost Story of Christmas</h2>
<div class="author">by Charles Dickens</div>
</div>
<div class="chapter" id="chapter-preface">
<h3 class="chapter-title">Preface</h3>
<p>I HAVE endeavoured in this Ghostly little book, to raise the Ghost of an Idea, which shall not put my readers out of humour with themselves, with each other, with the season, or with me. May it haunt their houses pleasantly, and no one wish to lay it.</p>
<p>Their faithful Friend and Servant,</p>
<p>C. D.</p>
<p>December, 1843.</p>
</div>
</body>
</html>
'的樂趣ction {'不是有效的JavaScript,應該是'function(){'。當某些事情不工作時,您應該檢查調試控制檯是否有錯誤。 – Blender
對不起,我的錯誤,謝謝:) @Blender – Vaibhav