元素内容增加,滚动条跟着滚动||获得元素的标签名

First Post:

Last Update:

元素内容增加,滚动条跟着滚动

1
2
$('.box').animate({scrollTop: $('.box')[0].scrollHeight}, 500);
// box 为需要滚动的容器

获得元素的标签名

document.getElementById("demo").tagName;

1
2
3
4
5
// jquery获取点击元素的标签名
$('#demo').click(function() {
console.log($(this)[0].tagName.toLowerCase());
// 在 HTML 中,tagName 属性的返回值始终是大写的,所以要转化为小写
});