Category Archives: JavaScript

[펌글] jQuery-UI Dialog의 타이틀바(titlebar) 제거하기

By | 12월 15, 2011

– 출처 : http://www.ke-cai.net/2009/05/remove-jquery-ui-dialogs-title-bar.html –  1. Hide it via it’s default CSS:      .ui-dialog-titlebar { display: none; };       * 주의 : This will change all dialog’s apperance. 2. Or add another CSS class, insetad of change them all.      .hide-title-bar.ui-dialog-titlebar { display: none; }      $(“#dialog”).dialog({ dialogClass: “hide-title-bar” }); 3. Remove title bar element… Read More »

자바스크립트 함수 호출시 null과 undefined 에 대한 정리

By | 12월 6, 2011

* 자바스크립트 함수 호출시 인수를 생략하고 호출할 경우와 인수에 null 을 넣고 호출할 경우,   함수 내부에서는 어떻게 해석하는지, 또 null과 undefined는 어떤 관계가 있는지 살펴보자. function test(arg){    var isNullValue            = (arg == null);    var isUndefinedValue  = (arg == undefined);    var isNull          … Read More »

jQuery를 사용하여 폼 파라미터 정리하기

By | 11월 30, 2011

* $(‘#formId’).serialize()    – 선택된 폼 객체 내의 모든 폼 요소들을 파라미터 문자열화 하여 리턴한다.    – 결과 예) check=check2&radio=radio1 * $(‘#formId’).serializeArray()       – 선택된 폼 객체 내의 모든 폼 요소들을 name-value 쌍의 json object 배열 객체로 리턴한다.    – 결과 예) [   {     name: “a”,     value: “1”   }        … Read More »

자바스크립트 콜백함수(callback function) 사용법

By | 11월 29, 2011

* 콜백함수 문법은 특정 함수의 동작이 끝남과 동시에, 다른 여러가지 함수를 호출해야 할 경우에 사용된다. // 콜백함수 정의 function callbackTest(arg){      alert(arg); } // 콜백함수를 호출할 함수 정의 function test( arg1, arg2, callback ){      if( typeof callback == “function” ){          callback();      } } // 함수 호출부… Read More »

[펌글] javascript delete 연산자(operator)

By | 11월 25, 2011

– 출처 : http://www.lovelgw.com/Blog/237 – Javascript 에서 DOM 객체를 다루거나 JQuery 를 이용해 다이나믹한 페이지를 작성하려 할때 객체를 변수에 담는 일을 많이 합니다. 여러 DOM객체를 불러 들이고 함수 내부에서 사용을 한 다음에 재 사용하지 않을때 delete 연산자를 이용하여 객체를 제거 해주는 것이 전체적인 속도 및 메모리 사용에 있어서 많은 잇점이 있습니다.  예를 들어 동적인 페이지를 작성하는 함수에서… Read More »

[펌글] jQuery 특수문자 (special character) 목록

By | 11월 23, 2011

– 출처 : http://www.xinotes.org/notes/note/958/ – The jQuery doc says:  If you wish to use any of the meta-characters (such as !”#$%&'()*+,./:;?@[\]^`{|}~) as a literal part of a name, you must escape the character with two backslashes: \\.  So what are these meta-characters? According to the CSS specification:  In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters… Read More »

jQuery 셀렉터 사용시 특수문자 (예: +)가 있을 경우의 사용법

By | 11월 23, 2011

<div id=”foo+”></div>  가 있다고 할 때 $(‘#foo\\+’)   => 이렇게 사용해야 찾아낸다. * 참고  그러나 위의 #foo\\+ 을 별도의 문자열로 구성하여 alert() 등으로 뿌려보면 \ 하나가 없어져서   #foo\+ 가 되는 것을 볼 수 있다. 아마도  코딩시에는 \\로 escape를 하지만, 메모리에 올라가서 String 객체가 되는 순간 \하나가 없어지는 것으로 보인다. 어쨌든 이 경우에도 jQuery는 정상적으로 selecting을 한다. 

jQuery로 사용자 이벤트(event) 만들어 사용하기

By | 11월 17, 2011

– 출처 : http://stackoverflow.com/questions/2857900/onhide-type-event-in-jquery – * 상황 설명     마치 onclick 이벤트처럼, ‘어떤 동작’을 수행할 때(특정 함수를 호출할 때)  특정 동작을 수행하게 하고 싶다.     그러나 그 동작이 jQuery에 built-in 된 이벤트가 아니기 때문에 bind() 를 사용할 수가 없다. 어떻게 해야 하는가? * 방법 1      – 실제로 ‘hide’ 이벤트는 존재하지 않지만, 마치 이벤트가… Read More »

[펌글] jQuery select box(콤보박스) 와 option의 제어

By | 11월 8, 2011

– 출처 : http://sexybear.tistory.com/146 – $(“<option></option>”) .attr(“selected”, “selected”) .text(“텍스트”) .attr(“value”, “값”) .appendTo(“#selectboxid”); $(“#selectboxid”) .change(function() { alert(this.value); }); * 참고    removeAttr(‘selected’) 도 염두에 두자

자바스크립트 소수점 이하 자릿수 지정 방법

By | 11월 8, 2011

– 출처 : http://mwultong.blogspot.com/2007/08/javascript-tofixed.html – * 숫자 객체의 함수인 toFixed(n) 을 사용하면 임의로 소수점 이하 자릿수를 지정할 수 있다.   (예) var num = 123.456         num.toFixed(5)  =>  123.45600   //자릿수를 맞추기 위해 나머지 부분을 0으로 채움         num.toFixed(2)  =>  123.46        //해당 자릿수로 반올림 처리 – 참고… Read More »