As you see I've got my images cut up and sprited, and the hover actions working and on the top two links (drug product development and process research + development) I have the links hooked up with some jquery to hide some content until their clicked on then it's shown.
Here's what I want to do that I can't quite figure out:
I want those bubbles to stay green when the content is being displayed for it. I know kinda how I can do it (have a class added to that link when it's clicked and the content is showing) but how to I tell the jquery/DOM to do that?
You also have a lot of repetitive code, maybe try and put that stuff into it's own function, so hiding all those div's is much easier:
function hideAll() { $('#research-dev').hide(400); $('#chem-dev').hide(400); $('#fermentation').hide(400); $('#analytical').hide(400); $('#regulatory').hide(400); $('#quality').hide(400); $('#strategy').hide(400); $('#chain').hide(400); $('#product-dev').hide(400); $('a').removeClass(\"active\"); // Also remove class on anchor };
Make the circles load as blue again, but still not keeping green on click.
So, I tried using "switchClass" instead, with same results. Not staying green. So I'm stuck again.
Here's my jquery:
$(document).ready(function() { // hides the slickbox as soon as the DOM is ready // (a little sooner than page load) $('#product-dev').hide(); $('#research-dev').hide(); $('#chem-dev').hide(); $('#fermentation').hide(); $('#analytical').hide(); $('#regulatory').hide(); $('#quality').hide(); $('#strategy').hide(); $('#chain').hide();
function hideAll() { $('#research-dev').hide(400); $('#chem-dev').hide(400); $('#fermentation').hide(400); $('#analytical').hide(400); $('#regulatory').hide(400); $('#quality').hide(400); $('#strategy').hide(400); $('#chain').hide(400); $('#product-dev').hide(400); $('a').removeClass(\"selected\"); // Also remove class on anchor };
// toggles the slickbox on clicking the noted link $('a.prod-dev').click(function() { hideAll(); $('#product-dev').show(400); addClass(\"selected\"); return false; });
<div id=\"blurb\"> <div id=\"product-dev\">Lorem ipsum dolor. Set frigilla a.</div> <div id=\"research-dev\">Set frigilla a. Lorem ipsum dolor. </div> <div id=\"chem-dev\">Lorem ipsum dolor. Lorem ipsum dolor. Set frigilla a.</div> <div id=\"fermentation\">Lorem ipsum dolor. Set frigilla a. Lorem ipsum dolor. </div> <div id=\"analytical\">Lorem ipsum dolor. Set frigilla a. Lorem ipsum dolor. Lorem ipsum dolor. </div> <div id=\"regulatory\"> Set frigilla a. Lorem ipsum dolor. Lorem ipsum dolor. Lorem ipsum dolor. </div> <div id=\"quality\">Lorem ipsum dolor. Lorem ipsum dolor. Set frigilla a.</div> <div id=\"strategy\">Lorem ipsum dolor. Set frigilla a. Lorem ipsum dolor. </div> <div id=\"chain\">Lorem ipsum dolor. Set frigilla a. Lorem ipsum dolor. </div> </div>
I don't know what I did wrong before. I even looked up the addClass thing on jquery.com and add the $(this) but couldn't get it to work. Whatever though now after I pasted in the way you have shown it does. Many, many thanks ;)!!!
If you view either of those pages in IE6/IE7 you will see little black dots when the hover/click effects are taking place (ie: the show/hide). Looks like an IE issue with the redrawing or whatever you call it. Solutions?
I'm using jquery to show/hid content on a website. I have just the part I'm trying to show/hid content with here:
http://dev.cssgirl.com/r/rondaxe/cmc.html
As you see I've got my images cut up and sprited, and the hover actions working and on the top two links (drug product development and process research + development) I have the links hooked up with some jquery to hide some content until their clicked on then it's shown.
Here's what I want to do that I can't quite figure out:
I want those bubbles to stay green when the content is being displayed for it. I know kinda how I can do it (have a class added to that link when it's clicked and the content is showing) but how to I tell the jquery/DOM to do that?
Thanks.
Lindsey
What's up with the jump and content being shown near bottom of circles when clicked in IE6?
$('a.research-dev').addClass(\"active\").click(function() {
hideAll();
$('#research-dev').show(400);
return false;
});
Then just have the active class replicate the hover class:
.cmc a:hover, .cms a.active {background:url(images/cmcon.gif);
}
You also have a lot of repetitive code, maybe try and put that stuff into it's own function, so hiding all those div's is much easier:
function hideAll() {$('#research-dev').hide(400);
$('#chem-dev').hide(400);
$('#fermentation').hide(400);
$('#analytical').hide(400);
$('#regulatory').hide(400);
$('#quality').hide(400);
$('#strategy').hide(400);
$('#chain').hide(400);
$('#product-dev').hide(400);
$('a').removeClass(\"active\"); // Also remove class on anchor
};
Bear Bibault' book is good too.
My first real messing around and editing things my way with jquery.
Really appreciate the help!
I tried this:
$('a.research-dev').addClass(\"active\").click(function() {hideAll();
$('#research-dev').show(400);
return false;
});
But it made all the circles green onload. So I tried switching it and adding the active class within the click(function() { like so:
$('a.research-dev').click(function() {hideAll();
$('#research-dev').show(400);
addClass(\"active\")
return false;
});
Make the circles load as blue again, but still not keeping green on click.
So, I tried using "switchClass" instead, with same results. Not staying green. So I'm stuck again.
Here's my jquery:
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
// (a little sooner than page load)
$('#product-dev').hide();
$('#research-dev').hide();
$('#chem-dev').hide();
$('#fermentation').hide();
$('#analytical').hide();
$('#regulatory').hide();
$('#quality').hide();
$('#strategy').hide();
$('#chain').hide();
function hideAll() {
$('#research-dev').hide(400);
$('#chem-dev').hide(400);
$('#fermentation').hide(400);
$('#analytical').hide(400);
$('#regulatory').hide(400);
$('#quality').hide(400);
$('#strategy').hide(400);
$('#chain').hide(400);
$('#product-dev').hide(400);
$('a').removeClass(\"selected\"); // Also remove class on anchor
};
// toggles the slickbox on clicking the noted link
$('a.prod-dev').click(function() {
hideAll();
$('#product-dev').show(400);
addClass(\"selected\");
return false;
});
$('a.research-dev').click(function() {
hideAll();
$('#research-dev').show(400);
switchClass('research-dev', 'research-on', 400);
return false;
});
$('a.chem-dev').click(function() {
hideAll();
$('#chem-dev').show(400);
addClass(\"selected\");
return false;
});
$('a.fermentation').click(function() {
hideAll();
$('#fermentation').show(400);
addClass(\"selected\");
return false;
});
$('a.analytical').click(function() {
hideAll();
$('#analytical').show(400);
addClass(\"selected\");
return false;
});
$('a.regulatory').click(function() {
hideAll();
$('#regulatory').show(400);
addClass(\"selected\");
return false;
});
$('a.quality').click(function() {
hideAll();
$('#quality').show(400);
addClass(\"selected\");
return false;
});
$('a.strategy').click(function() {
hideAll();
$('#strategy').show(400);
addClass(\"selected\");
return false;
});
$('a.chain').click(function() {
hideAll();
$('#chain').show(400);
addClass(\"selected\");
return false;
});
});
And my CSS/HTML
What am I doing wrong here?
Demo is here:
http://dev.cssgirl.com/r/rondaxe/cmc.html
$('a.research-dev').click(function() {hideAll();
$('#research-dev').show(400);
$(this).addClass(\"active\");
return false;
});
That will add the class only when you click, which is what you want I think.
happens once in a blue moon.
And I got the finished product up finally if you all want to check it out:
http://dev.ketanvakil.com/rondaxe.com/s ... ulting.php
and
http://dev.ketanvakil.com/rondaxe.com/services/
I even figured out the .hover solution for show/hide all by myself :) Practice, practice, practice!
Thanks again guys!
If you view either of those pages in IE6/IE7 you will see little black dots when the hover/click effects are taking place (ie: the show/hide). Looks like an IE issue with the redrawing or whatever you call it. Solutions?
You can workaround it easily by using the sliding effects:
.slideUp()
.slideDown()
.slideToggle()
instead of
.show()
.hide()
.toggle()
James