gpt4 book ai didi

javascript - 单击按钮时无法增加字体大小

转载 作者:行者123 更新时间:2023-12-03 12:11:53 24 4
gpt4 key购买 nike

我想在单击特定按钮时更改两个 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(){

关于javascript - 单击按钮时无法增加字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24925755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com