Solved

jquery accordion change actions

Posted on 2013-12-20
5
550 Views
Last Modified: 2013-12-20
Hello I have this code:

<!-- Header Code -->

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    
    <style>
    #accordion-resizer {
        padding: 10px;
        width: 350px;
        height: 500px;
    }
    </style>
    <script>
    $(function() {
        $( "#accordion" ).accordion({
            heightStyle: "fill"
        });
    });
    $(function() {
        $( "#accordion-resizer" ).resizable({
            minHeight: 140,
            minWidth: 200,
            resize: function() {
                $( "#accordion" ).accordion( "refresh" );
            }
        });
    });
    </script>


<!-- Body Code -->



<!-- HTML frag_1 -->

<!--Preamble-->
<div style="position:absolute;left:51px;top:66px;width:236px;height:170px; /*MainDivStyle*/" __AddCode="here">
    <h3 class="docs">Drag bottom right corner to resize</h3>
 
<div id="accordion-resizer" class="ui-widget-content">
    <div id="accordion">
        <h3>Section 1</h3>
        <div>
            <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
        </div>
        <h3>Section 2</h3>
        <div>
            <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p>
        </div>
        <h3>Section 3</h3>
        <div>
            <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
            <ul>
                <li>List item one</li>
                <li>List item two</li>
                <li>List item three</li>
            </ul>
        </div>
        <h3>Section 4</h3>
        <div>
            <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
        </div>
    </div>
</div>
</div>
<!--Postamble-->

Open in new window


   I want:
1.-to make that when you enter at first time on the page all tbas are closed because in this demo always begin with section 1 opened. I want to be closed section 1 when first time load the page and then you click on any section to open
2.-For example if you click section 2 you open section 2 but if you click again section 2 not close. I want to close the tab opened too if you click in the same tab section.
3.-Is there a way to change the colors of the title on the sections for example change "Section 1" background color and the background text and font when is opened the section change too. On the same way for other sections.
   If someone help me adding mods to the code I used  I don´t understand very well jquery and I very confused with all for now.
Thank you
0
Comment
Question by:coerrace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39732562
To start off closed http://jsbin.com/IziKesak/1/edit?html,output
 $(function() {
        $( "#accordion" ).accordion({
            heightStyle: "fill",
           active: false,
           collapsible: true
        });
    });
    $(function() {
        $( "#accordion-resizer" ).resizable({
            minHeight: 140,
            minWidth: 200,
            resize: function() {
                $( "#accordion" ).accordion( "refresh" );
            }
        });
    });

Open in new window


If you want to change the background of the accordion header, you should be able to override the css for the ui by adding below to a style tag or external style sheet BELOW the jquery ui css.
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {

}

Open in new window

0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39732587
I found this demo for adding styles http://demo.hongkiat.com/jquery-ui-accordion/index.html and applied the css to the demo and it works.  http://jsbin.com/IziKesak/2/edit?html,css,output

Is this what you want?
0
 

Author Comment

by:coerrace
ID: 39732635
wow padas thank you so much exactly is what I need in all points all solved.
Thank you so much you saved my life
0
 

Author Closing Comment

by:coerrace
ID: 39732641
Excellent solution
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39733289
Glad it worked out!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question