加减去手风琴可点击

时间:2017-08-17 06:42:14

标签: javascript php jquery

    ## Clickable plus minus accordion ##

我有手风琴可点击的html只加上减去,想要崩溃加上减去按钮点击它只在第一级工作但我也想在第二级我正在尝试但它不工作建议我在哪里我错了这里是链接我选择了这个例子,请参阅该链接以获取更多信息 https://bootsnipp.com/snippets/featured/full-clickable-panel-heading

<!DOCTYPE html>
		<meta name="robots" content="noindex">
		<html>
		<head>
		<script src="http://code.jquery.com/jquery.min.js"></script>
		<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
		<meta charset="utf-8">
		<title>JS Bin</title>
		<style type="text/css">
		.clickable
		{
			cursor: pointer;
		}

		.clickable .glyphicon
		{
			background: rgba(0, 0, 0, 0.15);
			display: inline-block;
			padding: 6px 12px;
			border-radius: 4px
		}

		.panel-heading span
		{
			margin-top: -23px;
			font-size: 15px;
			margin-right: -9px;
		}
		a.clickable { color: inherit; }
		a.clickable:hover { text-decoration:none; }
		</style>
		</head>
		<body>
		<div class="container">
			<div class="row">
				<div class="col-md-6">
					<div class="panel panel-primary">
						<div class="panel-heading">
							<h3 class="panel-title">
								core service
							</h3>
							<span class="pull-right clickable"><i class="glyphicon glyphicon-minus"></i></span>
						</div>
						<div class="panel-body">
							<div class="panel panel-info">
								<div class="panel-heading">
									<h3 class="panel-title">
										Panel 3
									</h3>
								<span class="pull-right clickable"><i class="glyphicon glyphicon-minus"></i></span>
								</div>
								<div class="panel-body">
									Panel content</div>
								</div>
							
						</div>
					</div>
				</div>
			</div>
		</div>
		  
		</body>
		<script>
		$(document).on('click', '.panel-heading span.clickable', function (e) {
			var $this = $(this);
			if (!$this.hasClass('panel-collapsed')) {
				$this.parents('.panel').find('.panel-body').slideUp();
				$this.addClass('panel-collapsed');
				$this.find('i').removeClass('glyphicon-minus').addClass('glyphicon-plus');
			} else {
				$this.parents('.panel').find('.panel-body').slideDown();
				$this.removeClass('panel-collapsed');
				$this.find('i').removeClass('glyphicon-plus').addClass('glyphicon-minus');
			}
		});
		$(document).on('click', '.panel div.clickable', function (e) {
			var $this = $(this);
			if (!$this.hasClass('panel-collapsed')) {
				$this.parents('.panel').find('.panel-body').slideUp();
				$this.addClass('panel-collapsed');
				$this.find('i').removeClass('glyphicon-minus').addClass('glyphicon-plus');
			} else {
				$this.parents('.panel').find('.panel-body').slideDown();
				$this.removeClass('panel-collapsed');
				$this.find('i').removeClass('glyphicon-plus').addClass('glyphicon-minus');
			}
		});
		$(document).ready(function () {
			$('.panel-heading span.clickable').click();
			$('.panel div.clickable').click();
		});

		</script>
		</html>

0 个答案:

没有答案