forEach循环dom元素

//让ie8支持foreach
		    if (typeof Array.prototype.forEach != 'function') {
			    Array.prototype.forEach = function(callback){
				    for (var i = 0; i < this.length; i++){
					    callback.apply(this, [this[i], i, this]);
				    }
			    };
		    }
		      
//dom使用forEach
function bingdingValue (originalSelector,bingdingSelector){
			var subInEles=document.querySelectorAll(originalSelector);
			var subOutEles=document.querySelectorAll(bingdingSelector);
			Array.prototype.forEach.call(subInEles, function(item,index) {
				Object.defineProperty(item,'id', {
					set:function (newVal) {
						//item.value=newVal;
						subOutEles[index].value=newVal;
					}
				})
			});
		},

唉,晚饭还没吃,线上出bug(我就补个别人的坑),然后补完坑打包忘了改版本号,使医院每台电脑都需要清缓存。。。
balabala,后来情绪没控制住和产品老大中的老大怼了一句。。。

posted @ 2018-03-21 20:04  以梦为马papapa  阅读(997)  评论(0编辑  收藏  举报