I have a standard ul list which contains five li elements. After the third element, I’ve placed a button in the list with the CSS class .morecats.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<button class="morecats">+</button>
<li>4</li>
<li>5</li>
</ul>
Using jQuery, I have hidden the first three li elements:
$('ul')
.find('li:gt(3)')
.hide()
.end();
Now, I’d like jQuery to fade in and show the hidden li elements when the user hovers over the button .morecats. I’d also like a separate div called .bgto fade in/appear.
How could this be accomplished?
One way to accomplish this would be through the jQuery hover function. The official example even has a fade in and fade out example you can look at.
The slice gets the last two
lielements.Jsfiddle: http://jsfiddle.net/wDLVQ/2/