API

事件(Events)

// 页面完全加载后执行(包括图形)
$(window).load(() => {
})
// DOM 结构完全渲染之后执行
$(document).ready(() => {
});
$( "li.fade" ).hover(function() {
  $( this ).fadeOut( 100 );
  $( this ).fadeIn( 500 );
});

过滤器(Filtering)

  • eq(): 通过下标匹配元素。

树形遍历(Tree)

元素(DOM )

// 安全清空(推荐)
$('#element').empty();
 
// 等效原生方法
document.getElementById('element').innerHTML = '';

index()

如果我们省略参数,.index() 将返回匹配元素集中第一个元素相对于其兄弟姐妹的位置

alert( "Index: " + $( "#bar" ).index() );

查看被点击项目的下标:

$(this.el).on("click", ".animation-item", (e) =>{
	const index = $('.animation-item').index(e.currentTarget);
	//...
})

样式属性(style)

属性

常见问题

val() 获取不到值

扩展阅读