Modify this jQuery accordion plugin so first tab is open on load -


i'm using code found jquery accordion because don't animation jqueryui accordion. 1 thing have first tab open automatically on load. else great, if has insight, appreciate it.

$(document).ready(function() {    $('.accordion .item .heading').click(function() {  		      var = $(this).closest('.item');      var b = $(a).hasclass('open');  	var c = $(a).closest('.accordion').find('.open');  		  	if(b != true) {  		$(c).find('.content').slideup(200);  		$(c).removeclass('open');  	}    	$(a).toggleclass('open');  	$(a).find('.content').slidetoggle(200);    	});  });
.accordion {    	width: 100%;    	border-radius: 5px;    	overflow: hidden;    	position: relative;    	left: 2em;  }  .accordion .item .heading {    	height: 50px;    	line-height: 50px;    	font-size: 17px;    	cursor: pointer;    	color: #fff;    	padding-left: 15px;    	background: #ee6363 url('arrow.png') no-repeat;    	background-position: right 20px top -95px;    	border-bottom: 1px solid #ec8484;    	box-sizing: border-box;  }  .accordion .item.open .heading, .accordion .item:last-child .heading {   	border: 0;   }  .accordion .item.open .heading {  	 background-position: right 20px top -5px;   }  .accordion .item .content {    	display: none;    	padding: 15px;    	background: #fff;    	font-size: 14px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    			<div class="accordion">    				<div class="item">      					<div class="heading">this first heading</div>      					<div class="content">this first content</div>    				</div>    				<div class="item">      					<div class="heading">this second heading</div>      					<div class="content">this second content</div>    				</div>    				<div class="item">      					<div class="heading">this third title</div>      					<div class="content">this third content</div>    				</div>  			</div>

just trigger click on first on pageload ?

$(document).ready(function() {    $('.accordion .item .heading').click(function() {  		      var = $(this).closest('.item');      var b = $(a).hasclass('open');  	var c = $(a).closest('.accordion').find('.open');  		  	if(b != true) {  		$(c).find('.content').slideup(200);  		$(c).removeclass('open');  	}    	$(a).toggleclass('open');  	$(a).find('.content').slidetoggle(200);    	}).first().trigger('click');  })
.accordion {    	width: 100%;    	border-radius: 5px;    	overflow: hidden;    	position: relative;    	left: 2em;  }  .accordion .item .heading {    	height: 50px;    	line-height: 50px;    	font-size: 17px;    	cursor: pointer;    	color: #fff;    	padding-left: 15px;    	background: #ee6363 url('arrow.png') no-repeat;    	background-position: right 20px top -95px;    	border-bottom: 1px solid #ec8484;    	box-sizing: border-box;  }  .accordion .item.open .heading, .accordion .item:last-child .heading {   	border: 0;   }  .accordion .item.open .heading {  	 background-position: right 20px top -5px;   }  .accordion .item .content {    	display: none;    	padding: 15px;    	background: #fff;    	font-size: 14px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    			<div class="accordion">    				<div class="item">      					<div class="heading">this first heading</div>      					<div class="content">this first content</div>    				</div>    				<div class="item">      					<div class="heading">this second heading</div>      					<div class="content">this second content</div>    				</div>    				<div class="item">      					<div class="heading">this third title</div>      					<div class="content">this third content</div>    				</div>  			</div>


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -