Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  134] [ 7]  / answers: 1 / hits: 62477  / 11 Years ago, sat, july 6, 2013, 12:00:00

so I feel(and hope) this is pretty simple. I am new to javascript and am trying to get this working. When I link to my external .js file from my html it does not function. However, when entering the script code directly into my HTML it DOES work.



Here is the js file:



$(document).ready(function(){
$(#flip).click(function(){
$(#panel).slideToggle(slow);
});
});


This is the index.html file:



<!DOCTYPE html>
<html>
<head>
<title>slidepanel test</title>
<script type=text/javascript src=script.js></script>
<link rel=stylesheet type=text/css href=style.css/>
</head>

<body>


<div id=flip>Click to slide the panel down or up</div>
<div id=panel>Hello world!</div>

</body>
</html>


and this is the CSS:



#panel,#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel
{
padding:50px;
display:none;
}

More From » jquery

 Answers
7

You are using jQuery, but it doesn't seem like you have included it. Add this to your HEAD element



<script type=text/javascript src=http://code.jquery.com/jquery-latest.js></script>

[#77161] Friday, July 5, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jonrened

Total Points: 627
Total Questions: 114
Total Answers: 99

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
jonrened questions
Mon, Nov 2, 20, 00:00, 4 Years ago
Tue, May 19, 20, 00:00, 4 Years ago
Tue, Jan 21, 20, 00:00, 4 Years ago
Thu, Nov 7, 19, 00:00, 5 Years ago
;