저는 주로 ajax를 구현할 때 prototype 라이브러리를 이용합니다.
너무 익숙해져 버려서...
위 링크는 한글로된 prototype 1.5 설명서 입니다.
한글뿐 아니라 다른 여러 나라 언어로도 확인가능하네요^^
prototype에 관심있으신 분들 즐겨찾기해 두시고 참고하기 좋은 사이트입니다.
// 공백 제거
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/gi, "");
}
// 문자열내의 모든 str1을 str2로 바꾸기
String.prototype.replaceAll = function(str1, str2)
{
var temp_str = "";
if (this.trim() != "" && str1 != str2)
{
temp_str = this.trim();
while (temp_str.indexOf(str1) > -1)
{
temp_str = temp_str.replace(str1, str2);
}
}
return temp_str;
}
사용예 )
var strValue = '123aa123';
document.write(strValue.replaceAll( '123', 'a');
// 결과 : aaaa
* String.prototype.replaceAll = function(str1, str2) <-- 요 부분이 이해가 안가시는 분은
http://www.prototypejs.org/learn/class-inheritance <-- 요기 참조해보세요.
String 클래스에 replaceAll 이라는 함수를 추가한다... 뭐 이런거에요.
* 이벤트 바로가기 : http://www.style777.com
혹시 하는 마음에 이벤트에 참여했다.
1년간 기름값만 내고 타면 된단다..
안그래도 똥차 바꾸고 싶은데. 이거 되면 1년 돈굳는다. 될까?