336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요.
HTML안에 태그를 추가하는 방법을 알려드릴꼐요.
ID를 이용해서 innerHTML를 추가할려고 합니다.
확인하고, 유용하게 쓰길 바래요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 |
<meta charset="utf-8"/>
<html>
<head>
<title>즐겨찾기 추가</title>
<script language="javascript">
//span1에 jdk's blog를 추가합니다.
function innerHTML_f(){
document.getElementById("span1").innerHTML = 'JDK\'s blog';
}
</script>
</head>
<body>
<span onclick='innerHTML_f()' id='span1'>123123</span>
</body>
</html>
|
cs |

일단 이렇게 결과가 나와요. 123123을 클릭하면..

JDK's blog가 나와요.
이렇게 해서 태그도 추가가 가능해요.
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요 이번엔 문자열 찾는 방법을 알려드릴꼐요.
찾을 문자열.indexOf("찾을 문자열");
을 쓰면 되는데요.
예제 소스를 보여드릴꼐요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
<script type="text/javascript">
function testAlert(){
var imsi = "jdk";
var position = imsi.indexOf("jddd");
if(position > -1){
console.log(imsi+"'s Blog");
}else{
console.log(imsi+" is not.");
}
}
</script>
<body onload = "testAlert()">
</body>
|
cs |
position은 해당 문자열이 어디있는지 가지고 있습니다.
해당 문자열이 포함되어 있다면, 포함된 위치가 나와서 -1보다는 크게 됩니다.
그렇지 않으면 다른문자열이 나옵니다.
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요
저번에 substirng함수를 알려드렸었죠..?
substr함수를 사용해서 문자열을 자르는 방법을 알려드릴께요
|
<script type="text/javascript">
function testAlert(){
var imsi = "2015-11-11";
console.log(imsi.substr(0,4)+"-"+imsi.substr(5,2)+"-"+imsi.substr(8,2));
}
</script>
<body onload = "testAlert()">
</body>
|
cs |
문자열.substr(시작문자열,가져올문자열수)를 쓰면 필요한 문자열을 가져올 수 있습니다.

이렇게 결과가 나왔어요.. substring으로 해결이 안됬다면 이렇게 처리해서 해결해 보는 것도 좋은거 같아요.
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안녕하세요.
자바스크립트에서 문자열 자르는 방법을 알려드릴꼐요
문자열.substring(시작위치,끝나는 위치); 로 나오는 간단한 방법을 알려드릴께요
|
<script type="text/javascript">
function testAlert(){
var imsi = "2015-11-11";
console.log(imsi.substring(0,4)+"-"+imsi.substring(5,7)+"-"+imsi.substring(8,10));
}
</script>
<body onload = "testAlert()">
</body>
|
cs |

이렇게 결과가 나옵니다. 필요한 문자를 잘라서 표기해서 유용하게 사용하세요 ㅎㅎ.
도움이 될지 모르겠네요