JQuery’s .slideUp() doesn’t work after .append() is used to append value of textarea to the div.
HTML:
<html>
<body>
<div id="cont">
<textarea id="txt"></textarea>
<button onclick="click()">Click</button>
</div>
</body>
</html>
JavaScript:
function click(){
var txt = $('#txt').val();
var html = document.createElement('div');
$(html).hide().html(txt);
$('#cont').append(html);
$(html).slideUp(500);
}
I can’t figure out what the problem is because when I used .show() instead of .slideUp() it works fine.
well…slideDown let the element be shown and slideUp let it be hidden. try
@ Philip Hardyhis saying: fixes my problem. However, is there a way to have it slide up from the bottom without having to use .animate()
i don’t think so, but I think it would be pretty easy:
just put a div-element inside of the html (with $(html) it will be hard to handle) lets call it “myDiv” and put every content of the html in myDiv
then move the div outside of the window and do the animation (note to move it outside at the bottom you need to temporary disable scrolls of window)
i think it should work like this