参考文献:JQ动画


1、显示与隐藏

1、slideToggle 方法 - 检查被选元素的可见状态。
2、slow- 动画缓动值。
3、scrollTop 方法 - 返回或者设置匹配元素的滚动条的垂直位置,方法对于可见元素和不可见元素具有效。

/* 支持JQ 1.10.2.min.js*/
$(function() {
	$(".downmenu").click(function() {
		$(".slideMenu").slideToggle("slow");
	})
	$(window).scroll(function() {
		/* 导航顶部 */
		if ($(window).scrollTop > 120 ) {
			$(".slideMenu").hide();
		}
	})
})

jq -常用功能小记(更新)


2、添加类

1、 attr 其实就是原生js中 getAttribute 的简化实现,设置或返回被选元素的属性和值,而removeAttr 就是 removeAttribute 的简写;
2、find() 方法返回被选元素的后代元素,即返回 paylist-item 后代中所有的 icon-select 元素;

 $(".paylist-item").click(function () {
 		//siblings是循环遍历
        $(".paylist-item").siblings().find(".icon-select").attr('class', 'icon-select');
        $(this).find(".icon-select").attr('class', "icon-select item-selecteds");
 })

jq -常用功能小记(更新)


3、添加、移除类

$(document).ready(function(){
  var liTags = $('.div').find('li');
  //$.each() 遍历处理二维数组  
  $.each(liTags,function(i,li) {
	  let cid = i
	  var _this = $(this)
	  _this.on('mouseover',function() {
		  var tops = $('.divs').find('.pp');
		  $.each(tops,function(i,top) {
			  var _this = $(this)
			  _this.removeClass('actives')
		  })
		  $.each(liTags,function(i,li) {
			  var _this = $(this)
			  _this.removeClass('active')
		  })
	  	  _this.addClass('active')
	  	  $('[cid='+cid+']').addClass('actives')
	  })
  })
})

jq -常用功能小记(更新)

相关文章:

  • 2021-06-01
  • 2021-04-25
  • 2021-09-13
  • 2021-08-21
  • 2021-06-01
  • 2022-12-23
  • 2021-10-28
猜你喜欢
  • 2021-11-21
  • 2021-08-01
  • 2021-06-02
  • 2021-07-03
  • 2021-08-24
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案