Fun and easy Jquery on your Drupal site
All of Digital Immersion's Drupal sites have Jquery plugged in and enabled. Jquery allows for a lot of neat tricks. Here's a quick example of code that will divide your content area into 3 tabs with content that fades in.
First the code:
<style type="text/css">
ul.jtabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px; /*--Set height of jtabs--*/
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 600px;
}
ul.jtabs li {
float: left;
margin: 0;
padding: 0;
height: 31px; /*--Subtract 1px from the height of the unordered list--*/
line-height: 31px; /*--Vertically aligns the text within the jtab--*/
border: 1px solid #999;
border-left: none;
margin-bottom: -1px; /*--Pull the list item down 1px--*/
overflow: hidden;
position: relative;
/* background: #e0e0e0; */
}
ul.jtabs li a {
text-decoration: none;
color: #FFF;
display: block;
font-size: 1.2em;
padding: 0 20px;
/* border: 1px solid #fff;*/ /*--Gives the bevel look with a 1px white border inside the list item--*/
outline: none;
}
ul.jtabs li a:hover {
background: #ccc;
}
html ul.jtabs li.active, html ul.jtabs li.active a:hover { /*--Makes sure that the active jtab does not listen to the hover properties--*/
/* background: #fff; */
border-bottom: 1px solid #fff; /*--Makes the active jtab look like it's connected with its content--*/
}
/* style paste 2 -------------------------------------- */
.jtab_container {
border: 1px solid #999;
border-top: none;
overflow: hidden;
clear: both;
float: left; width: 600px;
/* background: #fff; */
-moz-border-radius: 5px;
border-radius: 5px;
}
.jtab_content {
padding: 20px;
font-size: 1.2em;
-moz-border-radius: 5px;
border-radius: 5px;
}</style>
<script>
$(document).ready(function() {
//When page loads...
$(".jtab_content").hide(); //Hide all content
$("ul.jtabs li:first").addClass("active").show(); //Activate first jtab
$(".jtab_content:first").show(); //Show first jtab content
//On Click Event
$("ul.jtabs li").click(function() {
$("ul.jtabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected jtab
$(".jtab_content").hide(); //Hide all jtab content
var activejtab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active jtab + content
$(activejtab).fadeIn(); //Fade in the active ID content
return false;
});
});</script><ul class="jtabs">
<li>
<a href="#jtab1">Model zesssf2344324</a></li>
<li>
<a href="#jtab2">Detailed stats</a></li>
<li>
<a href="#jtab3">More pics</a></li>
</ul>
<div class="jtab_container">
<div class="jtab_content" id="jtab1">
The wang-dizzle 3000 has vastly more wang and slightly more dizzle than the competitors.</div>
<div class="jtab_content" id="jtab2">
<!--Content--> fsafsafdssdfasd</div>
<div class="jtab_content" id="jtab3">
<!--Content--> asfd;oipwerproweie</div>
</div>
And here's what it does:
- Login to post comments