无法在单击按钮时增加字体大小
Unable to increase font size on click of a button
我想改变两个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>
语法错误
尝试更换
$(document).ready(function{
$(document).ready(function(){
试试这个
$('#header h2, #chapter-preface h3, #chapter-preface p').addClass('large');
相关文章:
- 根据元素高度和宽度的百分比变化增加或减少字体大小
- 使用jquery在按钮点击事件中增加整个网页的字体大小
- 增加了“上传”按钮的文本字体大小
- JQuery功能,可在任何地方增加字体大小
- 增加 em 的字体大小
- 如何增加安卓应用程序的jqMath公式的字体大小
- 如何增加推特提要小部件的宽度和字体大小
- 如何让用户通过单击文本来增加字体大小
- 增加/减少页面上所有元素字体大小的有效方法
- 增加选项卡式导航中文本的字体大小
- 按比例增加整个网站的每个字体大小
- 如何通过快捷方式增加和减少字体大小?(tinymce)
- 通过javascript在每次点击时动态增加字体大小
- 无法在单击按钮时增加字体大小
- 我如何动态地增加字体大小与Javascript和为什么是我目前的功能不工作
- 如何使用jquery增加字体大小?
- 标签云——根据编号增加字体的权重
- Css保持表格宽度保持不变,而用户按ctrl +在chrome上增加字体大小
- 只需使用JavaScript点击按钮即可增加字体大小
- Jquery自动完成聚焦项增加字体大小