<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>随机名言</title>
<link rel="stylesheet" href="index.css">
<script>
$(document).ready(function() {
$(".btn-new").on("click", function() {
$(".quote").html("Here is the message");
});
});
</script>
</head>
<body>
<main class="qtbox">
<section class="qtbox-change">
<q class="quote">
Soylent Green is people! Soylent Green is people! Soylent Green is people! Soylent Green is people!
</q>
<p class="author">-- 陈思</p>
</section>
<section class="qtbox-btngroup">
<button class="btn btn-qq"></button>
<button class="btn btn-weibo"></button>
<button class="btn btn-new">New quote</button>
</section>
</main>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous">
</script>
</body>
</html>
css
html {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
body {
display: flex;
justify-content: center;
background-color: #000;
}
.qtbox {
width: 600px;
height: 130px;
padding: 25px 50px;
background-color: #fff;
border-radius: 2.5%;
}
.author {
text-align: right;
}
.qtbox-btngroup {
position: relative;
}
.qtbox-btngroup {
width: 83%;
margin-left: 8.5%;
margin-right: 8.5%;
}
.qtbox-btngroup .btn {
font-size: 16px;
color: #fff;
background-color: #000;
height: 38px;
border: 0;
cursor: pointer;
transition: background-color 1s ease-in;
}
.qtbox-btngroup .btn:focus {
outline: none;
}
.qtbox-btngroup .btn:hover {
opacity: 0.7;
}
.qtbox-btngroup .btn-new {
font-family: Arial, Verdana, Sans-serif;
position: absolute;
right: 0;
border-radius: 3px;
}
.qtbox-btngroup .btn-weibo,
.qtbox-btngroup .btn-qq {
width: 40px;
border-radius: 100%;
}
.qtbox-btngroup .btn-qq {
background: url("images/index-qq.png") center center no-repeat #000;
}
.qtbox-btngroup .btn-weibo {
background: url("images/index-weibo.png") center center no-repeat #000;
}
请把头部的script标签移到jquery后面