목록Programming/JavaScript, Json (10)
by Nathan
1234567891011121314var aMap = new Map();aMap.set("aa", "value");aMap.set("bb", "value");aMap.set("cc", "value");aMap.size; // 3aMap.get("dd"); // undefinedaMap.has("dd"); // falseaMap.delete("aa");aMap.clear(); // 전체삭제 // 확인용aMap.forEach(function(value, key){ console.log(key + " = " + value);});Colored by Color Scriptercs
12$('#id').prop('readonly', true); // 속성 추가$('#id').prop('readonly', false); // 속성 cs
12345678910111213141516var list = new Array(); var vo = new Object();vo.a = "aaa";vo.b = "bbb";vo.c = "ccc"; var vo1 = new Object();vo1.a = "aaa";vo1.b = "bbb";vo1.c = "ccc"; list[0] = vo;list[1] = vo1; console.log(list);cs
HTML12 AAA BBBcs JS12345678function setDisplay(){ if($('input:radio[id=aaa]').is(':checked')){ $('#divId').hide(); }else{ $('#divId').show(); }} Colored by Color Scriptercs
1. for .. in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // Initialize object. a = {"a" : "Athens" , "b" : "Belgrade", "c" : "Cairo"} // Iterate over the properties. var s = "" for (var key in a) { s += key + ": " + a[key]; s += " "; } document.write (s); // Output: // a: Athens // b: Belgrade // c: Cairo Colored by Color Scripter cs 2. for 1 2 3 4 5 var array = ['A', 'B', 'C', 'D']; for(var i=0; i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..
123456789101112131415161718192021222324252627function validation(formName){ var emptyCnt = 0; var obj_name; var obj_data; var obj_essntl; formName = formName != undefined ? '#' + formName + ' ' : ''; $(formName + ' input[essntl],'+ formName +' textarea[essntl],'+ formName +' select[essntl]').each(function(idx) { obj_name = $(this).attr("title"); obj_data = $.trim($(this).val()); obj_essntl = $(t..
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816..
1. javascript location.href : http://localhost:8080/test/main.do?param=value location.protocol : http: location.host : localhost:8080 location.pathname : /test/main.do location.search : ?param=value 2. jquery $(location).attr('href') : http://localhost:8080/test/main.do?param=value $(location).attr('protocol') : http: $(location).attr('host') : localhost:8080 $(location).attr('pathname') : /test..
1. js (client) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 jQuery(document).ready(function($){ //버튼 $("#btn_test").click(function(){ var bSubmit = true; if(bSubmit){ $.ajax({ url : '/test/testJson', type : 'POST', data : { param1 : "abcd" param2 : $("#param2").val(), param3 : $("#param3").val() }, dataType : "json", success : function(data) { i..