我正在尝试通过Jquery动画功能更改引导巨人。但这是行不通的。我希望在单击动画按钮后,超大屏幕尺寸会增加我的屏幕一半。
<div class="content">
<div class="jumbotron jumbotron-fluid">
<div class="container">
<div class="display-4">
<div class="display-4 heading">JQuery Practice</div>
<p class="lead">
This is Jquery Practice Session. Jquery is a javascript
library to make developers life better.
Let's make our jQuery learning fun.
</p>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class="p-2">
<button type="button" class="btn btn-success" id="animate">Animate</button>
</div>
</div>
jQuery是:
$(document).ready(function() {
$("animate").click(function() {
$("jumbotron").animate({
height:50vh
});
});
});
答案 0 :(得分:0)
$(document).ready(function(){
$("#animate").click(function(){
$(".jumbotron").animate({
height: "50vh"
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div class="content">
<div class="jumbotron jumbotron-fluid">
<div class="container">
<div class="display-4">
<div class="display-4 heading">JQuery Practice</div>
<p class="lead">
This is Jquery Practice Session.Jquery is a javascript library to make developers life better.
Let's make our jquery learning fun.
</p>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class="p-2">
<button type="button" class="btn btn-success" id="animate">Animate</button>
</div>
</div>
</body>
</html>
据我了解,您想animate的jombotron
格的高度。试试这个代码,
$("#animate").click(function(){
$(".jumbotron").animate({
height: "50vh"
});
});
答案 1 :(得分:0)
这是您使用的是jQuery slim,而不是实际的jQuery。另外,由于animate
是id并且jumbotron
是类,因此您没有正确选择元素。请检查此工作代码的codepen链接:
https://codepen.io/rohitmittal/pen/VRgVEP
希望它对您有帮助。