Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery accordion change actions

Posted on 2013-12-20
5
Medium Priority
?
562 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
  • 3
  • 2
5 Comments
 
LVL 54

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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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 54

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

972 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