您当前的位置: 首页 >  前端

杨林伟

暂无认证

  • 3浏览

    0关注

    3337博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

前端基础 -JQuery之遍历

杨林伟 发布时间:2019-03-20 15:44:02 ,浏览量:3

JQuery遍历 两种遍历方式:
jquery对象.each(function(index,ele){
		//this	  遍历后的结果   js对象
		//ele     遍历后的结果   js对象
		//index   索引
})
$.each(jquery对象,function(index,ele){
				//this	  遍历后的结果   js对象
				//ele     遍历后的结果   js对象
				//index   索引
	})
案例:遍历隐藏域的值

直接上代码:




	
		
		05-可见性过滤选择器.html

		
		
			$(function() {

				$("#b1").click(function() {

					/*
					 * 方式一:
					 * 
					 * $("[type=hidden]").each(function() {
						alert(this.value);
					});
					
					* 
					* */

					//方式二:
					$("[type=hidden]").each(function(index, val) {
						alert(index + " : " + val.value);
					});

				})

				$("#b2").click(function() {
					$.each($("[type=hidden]"), function(index, val) {
						alert(index + " : " + val.value);
					});
				})

			});
		
	

	

		
		
		

		
		
		
		
		

	


关注
打赏
1662376985
查看更多评论
立即登录/注册

微信扫码登录

0.1962s