Created
November 22, 2012 16:35
-
-
Save ohrstrom/4132027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>jQuery</title> | |
<script src="js/lib/jquery-1.8.3.min.js"></script> | |
<style type="text/css"> | |
body { | |
padding: 0; | |
margin: 0; | |
font-family: helvetica; | |
font-size: 10px; | |
} | |
div.list { | |
} | |
div.list > .item { | |
background: black; | |
height: 10px; | |
width: 100px; | |
margin-top: 2px; | |
} | |
div.list > .item.hover { | |
background: #ff00ff; | |
} | |
div.list > .item.active { | |
background: #00ffff; | |
} | |
div.list > .item > h1 { | |
display: none; | |
line-height: 10px; | |
font-size: 16px; | |
margin: 0; | |
padding: 4px 20px 0 0; | |
text-align: right; | |
color: white; | |
} | |
div.list > .item.hover > h1 { | |
display: block; | |
} | |
div.list > .item > .content { | |
display: none; | |
} | |
div.list > .item.active > .content { | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="list"> | |
<div class="item"> | |
<h1>Item 1</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
<div class="item"> | |
<h1>Item 2</h1> | |
<div class="content"> | |
<ul> | |
<li>Bla</li> | |
<li>Blu</li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<script src="js/jquery.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code... | |
myFunction = function() { | |
console.log('my name...'); | |
} | |
$(function(){ | |
console.log('dom ready'); | |
$('div.list') | |
.on('mouseenter', '.item', function(event){ | |
$(this).addClass('hover'); | |
$(this).animate({ | |
'width': '100%', | |
'height': '20px' | |
}, 100); | |
}) | |
.on('mouseleave', '.item', function(event){ | |
$('div.list .item').removeClass('active'); | |
$(this).removeClass('hover'); | |
$(this).animate({ | |
'width': '100px', | |
'height': '10px' | |
}, 100); | |
}) | |
.on('click', '.item', function(event){ | |
$('div.list .item').removeClass('active'); | |
$(this).addClass('active'); | |
$(this).animate({ | |
'width': '100%', | |
'height': '100px' | |
}, 100); | |
}) | |
; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment