Discussion & Help for all web coding and scripting. Some languages include PHP, Ruby, Perl, XHTML, CSS, Javascript and XML.
by commonguy » Fri Jan 15, 2010 2:50 am
- Code: Select all
<html>
<head>
<script language="javascript" type="text/javascript" src="misc/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(".moreless").click(function () {
$(".descr").slideToggle("slow");
});
</script>
<style type="text/css">
html {
font-family:sans-serif;
}
.report {
padding-top:5px;
padding-bottom:5px;
padding-right:5px;
padding-left:5px;
}
</style>
</head>
<body>
<div class="report" style="background-color:#ffdada;">
<div style="overflow:auto;">
<div style="float:left; margin-right:0.5%;">
<object data="misc/attention.svg" type="image/svg+xml" style="height:20pt; width:21pt;"></object>
</div>
<div style="color:#550000; float:left;">This is the Report Title</div>
<div class="moreless" style="float:right; text-align:right;">More</div>
</div>
<div class="descr">
This is a sample description.
</div>
</div>
</body>
</html>
I am trying to get SPAN class descr to slide up and down, but it doesn't seem to be happening. How do I get it to happen?
-
commonguy
- New around here
-
- Posts: 9
- Joined: Sun Aug 02, 2009 7:25 pm
-
by clintfloyd » Thu Jan 21, 2010 11:00 pm
Hi, you should put your jquery code inside this
- Code: Select all
$(document).ready(function(){
//Your code goes here...
});
and you have an error with your click event. Please see below, it must be working now

- Code: Select all
$(document).ready(function(){
$(".moreless").click(function(event){
$(".descr").slideToggle("slow");
});
});
--

-
clintfloyd
- New around here
-
- Posts: 20
- Joined: Thu Sep 10, 2009 12:10 am
- Location: Republic of the Philippines
-
by commonguy » Fri Jan 22, 2010 2:59 am
Cool, thanks. Why do you need to put the code on the script?
- Code: Select all
$(document).ready(function(){
//Your code goes here...
});
-
commonguy
- New around here
-
- Posts: 9
- Joined: Sun Aug 02, 2009 7:25 pm
-
by spaceship9 » Tue Feb 02, 2010 4:44 am
commonguy wrote:Cool, thanks. Why do you need to put the code on the script?
- Code: Select all
$(document).ready(function(){
//Your code goes here...
});
to make sure the jquery library has finished downloading before the browser tries to interpret that javascript
-
spaceship9
- Global Moderator
-
- Posts: 18
- Joined: Sun Jul 19, 2009 3:23 pm
-
Return to Coding and Programming
Who is online
Users browsing this forum: No registered users and 1 guest