<div class="codetitle"> <span><a style="CURSOR: pointer" data="64524" class="copybut" id="copybut64524" onclick="doCopy('code64524')"><u>コードをコピー</u></a></span> コードは次のとおりです。</div> <div class="codebody" id="code64524"> <br><tbody > <br><tr > ; <br><td >1</td><br><td>大幅割引</td><br><td>2011-11-11</td> > <td>SMS 通知</td> <br><tr> <br><td> ;大きな割引<br><br><td>SMS 通知<br> <br> <br></table> <br><br><div class="span7" id="right" > <table id=”table1”>input type="checkbox" name="checkbox" id="btn"/>すべて選択<br><td>SMS</td> ><td>アップロード時間</td> <br></tr> <br></thead> > <br><tr class="dragableBox" id="box1" > <br><td id="45"> ;/td><br><td>会議を行ったが、</td><br></td> </td> <br><br><tr class="dragableBox" id="box2"<td> input type="checkbox" name= "box2" /> <br>2<td> 会議で問題が見つかりました</td> -30</td> <br><td></td> <br><br><tr class="dragableBox" id="box3" ()"> <br><td> <input type="checkbox" name="box3" /> <br>3</td> <br><td>2011-01-30</ td><BR><td>五</td><BR><BR><tr class="dragableBox " id="box4"> ; <input type="checkbox" name="box4" /> <br>4</td>会議の検出</td> -01-30</td> <br><td></td> <br><br><tr class="dragableBox" id="box5"> <br><td> <input type="checkbox" name="box5"/> <br>5</td> 会議を行ったところ、<br> /td><br><br>2011-01-30</td><br></tr> ="dragableBox" id="box6" onclick="clickDrop()" > <br><td> <input type="checkbox" name= "box6" /> <br><td>< /td> <br><br><tr class="dragableBox" name="box7" /> 7</td>会議が見つかりました</td> 2011-01-30</td> 5</td> <br></tbody> <br></table> ;input type="button" value="test2();" /> <br><script type="text/javascript"> <br>var map = new HashMap(); <br>$("#table1 tr "); click(function(e){ <br>var trId=this.id; <br>$("input[type='checkbox' ]").each(function(){//トラバース ID <br>if(this .name==trId){ <br>if(this.checked==true){ <br>$(this).attr( "checked",false); <br>map.remove(this.name); 🎜>var dd=document.getElementById(trId); <br>dd.style.backgroundColor= "white"; <br>}else { <br>$(this).attr("checked",true); >map.put(this.name,trId); <br>var dd=document.getElementById(trId); <br>dd.style.backgroundColor= " <br>} <br><br>} <br><br>}); <br><br><br>});<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="56238" class="copybut" id="copybut56238" onclick="doCopy('code56238')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code56238"> <br>function HashMap() <br>{ <br>/**Map size **/ <br>var size = 0; <br>/**Object **/ <br>var entry = new Object(); <br><br>/**live **/ <br>this.put = function (key , value) <br>{ <br>if(!this.containsKey(key)) <br>{ <br>size ; <br>} <br>entry[key] = value; <br>} <br><br>/**Pick **/ <br>this.get = function (key) <br>{ <br>if( this.containsKey(key) ) <br>{ <br>return entry[key]; <br>} <br>else <br>{ <br>return null; <br>} <br>} <br><br>/**delete **/ <br>this.remove = function ( key ) <br>{ <br>if( delete entry[key] ) <br>{ <br>size --; <br>} <br>} <br><br>/**Whether to include Key **/ <br>this.containsKey = function ( key ) <br>{ <br>return (key in entry); <br>} <br><br>/**Whether to include Value **/ <br>this.containsValue = function ( value ) <br>{ <br>for(var prop in entry) <br>{ <br>if(entry[prop] == value) <br>{ <br>return true; <br>} <br>} <br>return false; <br>} <br><br>/**All Value **/ <br>this.values = function () <br>{ <br>var values = new Array(size); <br>for(var prop in entry) <br>{ <br>values.push(entry[prop]); <br>} <br>return values; <br>} <br><br>/**All Key **/ <br>this.keys = function () <br>{ <br>var keys = new Array(size); <br>for(var prop in entry) <br>{ <br>keys.push(prop); <br>} <br>return keys; <br>} <br><br>/**Map Size **/ <br>this.size = function () <br>{ <br>return size; <br>} <br>} <br><br>// var map = new HashMap(); <br><br>/* <br>map.put("A","1"); <br>map.put("B","2"); <br>map.put("A","5"); <br>map.put("C","3"); <br>map.put("A","4"); <br>*/ <br><br>/* <br>alert(map.containsKey("XX")); <br>alert(map.size()); <br>alert(map.get("A")); <br>alert(map.get("XX")); <br>map.remove("A"); <br>alert(map.size()); <br>alert(map.get("A")); <br>*/ <br><br>/**You can also use the object as Key **/ <br>/* <br>var arrayKey = new Array("1","2","3","4"); <br>var arrayValue = new Array("A","B","C","D"); <br>map.put(arrayKey,arrayValue); <br>var value = map.get(arrayKey); <br>for(var i = 0 ; i < value.length ; i ) <br>{ <br>//alert(value[i]); <br>} <br>*/ <br>/**When an object is used as a Key, the toString() method of the object is automatically called. In fact, the String object is ultimately used as the Key**/ <br><br>/**If it is a custom object, you have to override the toString() method. Otherwise, . will be the following result **/ <br><br>// function MyObject(name) <br>// { <br>// this.name = name; <br>// } <br><br>/**<br>function MyObject(name) <br>{ <br>this.name = name; <br><br>this.toString = function () <br>{ <br>return this.name; <br>} <br>} <br>**/ <br>// var object1 = new MyObject("小张"); <br>// var object2 = new MyObject("小名"); <br>// <br>// map.put(object1,"小张"); <br>// map.put(object2,"小名"); <br>// alert(map.get(object1)); <br>// alert(map.get(object2)); <br>// alert(map.size()); <br>// <br>/**Running result Nickname Nickname size = 1 **/ <br><br>/**If you change it to an object that overrides the toString() method, the effect will be completely different **/ <br> </div> </td> </div>