jn025
jn025

Reputation: 2895

jquery slide up for hidden element

$(function(){
    $('#twittercontent').hide();
});

$('#twitter').on('click', '.hvtext',function(){
    $('#twittercontent').slideUp('slow');
});

#twittercontent {
    background:rgba(255,0,0,1);
    width:320px;
    height:310px;
    display:block;
    z-index:205;
    position:absolute;
    top:5em;
    left:20em;
}

The div 'twittercontent' is a div that is called when clicking '.hvtext'. It is hidden while not clicked and when called I want it to slide up.

.slideDown works but .slideUp does not. I'd prefer it to slide up, is there any reason why .slideUp isn't working in this case?

Upvotes: 0

Views: 1779

Answers (1)

Richard Peck
Richard Peck

Reputation: 76784

Further to Arun P Johny's comment, you have to work out what you're trying to achieve with this

JS works with DOM elements, so it can only perform CSS-based styling in a way which is conducive with HTML principles (I.E it cannot hide a hidden element)


JSFiddle

I made a JSFiddle for you

I don't really get what you're trying to do, but I guess you could use the SlideToggle function, like this:

$('#twitter').on('click', '.hvtext',function(){
    $('#twittercontent').slideToggle('slow');
});

Upvotes: 1

Related Questions