var map = new Map(); map.set("1","a"); map.set("2","b"); map.set("3","c"); map.set("2","dd"); console.log(map.size); map.forEach(function (item) { console.log(item.toString()); });
输出如下
3
a
dd
c
var map = new Map(); map.set(1,"a"); map.set(2,"b"); map.set(3,"c"); map.set(2,"dd"); console.log(map.get(1));
select_map.delete($(this).attr("id"));
select_map.forEach(function (value, key) { console.log(key+"__"+value); }); map.forEach(function (item) { console.log(item.toString()); });
var select_map = new Map(); var xiaofeiText =""; //这里需要 添加输入 框的监听 如果有焦点了。把下面菜单 隐藏 $(function() { listen_xiaofei(); }); function listen_xiaofei(){ var fuwuList = $("#xiaofeiList").find(".fuwu_btn"); console.log($(fuwuList.size())); $(fuwuList).click(function(){ $(this).addClass("fuwu_select"); $(this).find("div").show(); //取消兄弟节点的选中效果 $(this).siblings().forEach(function (value, key) { if(key==this_id){ flag = true; } }); //取消兄弟节点的选中效果 var this_id = $(this).attr("id"); var flag = false; select_map.forEach(function (value, key) { if(key==this_id){ flag = true; } }); if(flag){ $(this).removeClass("fuwu_select"); $(this).find("div").hide(); select_map.delete($(this).attr("id")); }else{ select_map.set($(this).attr("id"),$(this).attr("text")); } xiaofeiText =""; select_map.forEach(function (value, key) { console.log(key+"__"+value); xiaofeiText = xiaofeiText+value+","; }); //删除最后的 豆号 xiaofeiText = xiaofeiText.substring(0,xiaofeiText.length-1); $("#xiaofeiText").html(xiaofeiText); }); }
map.hasOwnProperty(key); 或 obj.hasOwnProperty(key);
for(var i=0;i<trList.size();i++){ var f =false; duan_ids_map.forEach(function (value, key) { if(key==biaoji_num){ f=true; } }); if(f){ duan_ids_map.set(biaoji_num,duan_ids_map.get(biaoji_num)+","+id); }else{ duan_ids_map.set(biaoji_num,id); } //设置标记便于我们获取 //console.log(test_num_array.length); } console.log(duan_ids_map); duan_ids_map.forEach(function (value, key) { console.log(key+"__"+value); });
站长微信:xiaomao0055
站长QQ:14496453