Accordion on my own


#1


My code work perfectly on code academy. My issue is when I try these exercises on my own local drive. Please help me get this going using an index.html file as well as a script.js file.


<!DOCTYPE html>
<html>
    <head>
    
  <title>My Title</title>
  <link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css'/>
        <script type='text/javascript' src='script.js'></script>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  
</head>
<body>
    <div id="mainContent">
        <h1>This is an According Example</h1>           
    </div>
    <div id="menu">
        <h3><a href="#">Heading for first sentence</a></h3>
        <div>
        <p>This is the first sentence.</p>
        </div>          
        <h3><a href="#">Heading for second sentence</a></h3>            
        <div>
        <p>This is the second sentence.</p>
        </div>
        <h3><a href="#">Heading for third sentence</a></h3>
        <div>
        <p>This is the third sentence.</p>
        </div>
    </div>
</body>
</html> 


here the js file

$(document).ready(function(){
    $('#menu').accordion();
});

What's wrong with this code? It just shows up as a plain html page.
sigh....
I just wanna practice......:confused:


#2

jquery-ui is required for accordion, you forgot to include it:

 <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.