我正在使用 JavaScript 和 jQuery 开发内容更改点击功能,它可以工作但很笨重。有没有办法在 JS 或 jQuery 中使这种过渡更顺畅?
$(document).ready(function() {
$("h1").click(function() {
if (document.getElementById("frst_hd").innerHTML === "World") {
document.getElementById("frst_hd").innerHTML = "Hello";
} else {
document.getElementById("frst_hd").innerHTML = "World";
}
});
});
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<h1 id="frst_hd">Hello</h1>
</body>
</html>
我是这门语言的新手,所以如果这个问题很容易解决,我很抱歉。感谢您的帮助
喵喵时光机
相关分类