我想将一些jquery代码转换为javascript代码,我转换了许多行,但我不知道如何将slideup,slidedown和appendTo转换为纯javascript。
jquery的
$('#recentpostbreaking li:first').slideUp( function () { $(this).appendTo($('#recentpostbreaking ul')).slideDown(); });
我从下面的网址得到一些想法,但没有用 https://gist.github.com/ludder/4226288
function slideDown(elem) {
elem.style.maxHeight = '1000px';
// We're using a timer to set opacity = 0 because setting max-height = 0 doesn't (completely) hide the element.
elem.style.opacity = '1';
}
/**
* Slide element up (like jQuery's slideUp)
* @param {Node} elem Element
* @return {[type]} [description]
*/
function slideUp(elem) {
elem.style.maxHeight = '0';
once( 1, function () {
elem.style.opacity = '0';
});
}