Variable Visions

Articles jQuery jQuery-opening-and-closing-read-more-box

tutorials - jQuery and Web-Development.

jQuery opening and closing read more box

Published Fri. Feb. 22, 2013

Use toogleClass with height: 0 to height: auto CSS rules, and use .text to toggle Show/Hide text.

                jQuery('.accordianholderbutton').click(function() {
                    jQuery(this).find('+ div').toggleClass('accordianholder2');
                    jQuery(this).text(jQuery(this).text() == 'Click here for less information' ? 'Click here for more information' : 'Click here for less information');


                jQuery.extend($.fn.disableTextSelect = function() {
                        return this.each(function(){
                        }else if($.browser.msie){
                            $(this).bind('selectstart',function(){return false;});
                            $(this).mousedown(function(){return false;});

<div class="accordianholderbutton">Click here for more information</div>

<div class="accordianholder">
<p>Lorem Ipsum Dolor.</p>

.accordianholderbutton {
    background:url( #f9d444 no-repeat right -3px;
    padding:10px 10px 10px 20px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    color: #000;
.accordianholderbutton:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8) !important;
.accordianholderbutton2 {
    background:url( #f9d444 no-repeat right -38px;
    color: #FFF;
.accordianholder {
.accordianholder2 {
    height:auto !important;

Tag(s): jQuery, .toggleClass, .text,