I've hit a roadblock and can't seem to find the solution on my own. Hopefully, someone out there can provide me with a hint.
I am trying to meet the following requirements:
- There should be a Newsblock within an HTML Page with a fixed width and height.
- Within this Newsblock, only the titles of the news should be visible.
- These news items should start off as "collapsed" by default and expand when the mouse is hovered over them.
- Since the 'Newsblock' has a limited height, a scrollbar should appear if the expanded news exceeds the block's height, allowing users to scroll down.
- The Newstitle and Newstext should always remain within the Newsblock.
So far, I have been able to fulfill all of these requirements except for the one regarding the Scrollbar. Whenever I try to access the Scrollbar while hovering over the currently expanded news, it collapses again and the Scrollbar disappears. It seems that my .hover function is set up to SlideUp whenever I leave the newsentry, causing the Scrollbar to vanish since it is not part of the newsentry div. I'm unsure about what changes I need to make in order to maintain an overall Scrollbar for the Newsblock without it disappearing when trying to reach it.
P.s.: Having a separate Scrollbar per Newsentry would look odd. That's why I want to somehow 'bind' the scrollbar to the parent container :S
HTML
<div id="newsblock">
<div> // There are some auto-generated divs that I have to work with, so the news entries are not direct children of the news block.
<div class="newsentry">
<div class="newstitle">...</div>
<div class="newstext">...</div>
</div>
... another 9 'newsentry' divs.
</div>
</div>
JS
$(".newsentry").hover(
function() {
$(this).children(".newstext").stop(true,true).slideDown();
},
function() {
$(this).children(".newstext").stop(true,true).slideUp();
}
);
CSS
.newsblock {
height: 200px;
overflow-y: auto;
}