Jquery 如何使用按钮在引导中导航旋转木马?
我有以下代码Jquery 如何使用按钮在引导中导航旋转木马?,jquery,html,css,twitter-bootstrap,Jquery,Html,Css,Twitter Bootstrap,我有以下代码 <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input type="button" id="myButton" value="click"/>
<div class="container"> <!--for carousel -->
<div class="well">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner">
<div class="item active" id="first_carousel">
<a href="#carousel-example-generic" role="button" data-slide="next" id="next_carousel" class="pull-right">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div><!-- First Carousel -->
<div class="item" id="second_carousel"><!-- Second Carousel -->
<a class="col-xs-1" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<strong>My Details</strong>
</div><!-- Second Carousel -->
</div>
</div>
</div> <!-- Well -->
</div> <!-- Container -->
</body>
</html>
JS-Bin
我的详细信息
当用户单击按钮时,我想导航到旋转木马的第二张幻灯片。我尝试了action=“#第二张幻灯片”,但没有成功。使用jQuery或Bootstrap还有其他解决方法吗
以下是我到目前为止得到的信息-您可以使用jquery执行以下操作:
<input type="button" id="myButton" value="click" onclick=" $('#carousel-example-generic').carousel('next');"/>
您还可以使用:
$(“#转盘示例通用”).carousel('prev')
如果要转到上一张幻灯片
编辑:
如果要转到特定幻灯片,可以使用该幻灯片的索引:
<input type="button" id="myButton" value="click" onclick=" $('#carousel-example-generic').carousel(1);"/>
但如果我再次单击该按钮,它将返回到幻灯片1。我只希望按钮移动到下一步-如果我第二次单击它,它应该留在幻灯片中。在jQuery中有可能做到这一点吗?您可以使用id:它只会像一个符咒一样转到第二个slideWorks。你救了我的命。非常感谢:)请参考这个。这个对你有帮助吗。@smraj-太基本了。不管怎样,我从下面的答案中找到了我想要的。