• 회원가입
  • 로그인
  • 구글아이디로 로그인

[JS-서기] JS 16강 - this객체, 조건분기, 속성설정

1,386  


예제1

 

<script>

function hz(a) { 

     window.alert(a.value);

}

</script>


<input type='button' value='홈짱닷컴 Homzzang.com' name='' class='' onclick='hz(this)'> 


결과 보기 

 

 

 

예제2

 

<script>

function hz(a) { 

     document.getElementById('homzzang').innerHTML = a.value;

}

</script>


<input type='button' value='홈짱닷컴 Homzzang.com' name='' class='' onclick='hz(this)'>


<div id='homzzang'><div>

 

 

결과 보기

 

 

 

예제3

 

<style>

.red {color:red;}

.blue {color:blue;}

</style>


<script>

function chk() { 

     var a = document.getElementById('hz').value;

     if(a == '') {

          document.getElementById('notice').innerHTML= '입력 X';

          document.getElementById('notice').setAttribute('class','red');

     } else {

          document.getElementById('notice').innerHTML= '입력 O';

          document.getElementById('notice').setAttribute('class','blue');

     }

}

</script>


<input type='text' name='hz' value='' placeholder='' id='hz'>

<input type='button' value='확인' name='' class='' onclick='chk()'>

<div id='notice'></div>


 

결과 보기

※ 대소문자 구별 주의


분류 제목
PHP-서기 php 10. 그외의 form관련 태그들 (input, textarea, select, option) ★★★…
PHP-서기 php 9. form 태그를 이용한 값의 전달 ★★★
PHP-서기 php 8. get방식의 전달과 테이블, 스타일태그의 사용 + 사칙연산
PHP-서기 php 7. Get방식을 이용한 변수의 전달 ★
PHP-서기 php 6. Hello PHP - 기본명령어 (include, echo, print, printf(), 변수…
PHP-서기 php 5. 웹서버/웹브라우져/PHP란 무엇인가
PHP-서기 php4. 스타일 시트
PHP-서기 php 3. 테이블 태그의 심화 - 셀합치기
PHP-서기 php 2. 하이퍼링크, 테이블태그의 사용방법 (HTML 기초)
JQ-샵투 제이쿼리( jQuery) 20강 - 총정리 기말고사
JQ-샵투 제이쿼리( jQuery) 19강 - 다른 js 프레임워크와 함께 사용하기 noConflict Method
JQ-샵투 제이쿼리( jQuery) 18강 - jQuery AJAX (아작스)
JQ-샵투 제이쿼리( jQuery) 17강 - DOM tree 내에서의 종횡무진 하기
JQ-샵투 제이쿼리( jQuery) 16강 - Dimensions: jQuery 를 이용해 객체의 면적 다루기
JQ-샵투 제이쿼리( jQuery) 15강 - jQuery 를 이용해 CSS 다루기
JQ-샵투 제이쿼리( jQuery) 14 강 - jQuery 를 이용해 Elements,Content를 추가, 제거 하…
JQ-샵투 제이쿼리( jQuery) 13 강 - jQuery DOM : text, html,val,attr 문서 객체 …
JQ-샵투 제이쿼리( jQuery) 12 강 - jQuery Chaining 여러 명령을 엮어서 사용하기
JQ-샵투 제이쿼리( jQuery) 11 강 - jQuery Callback Functions 진행 중 효과를 다 실행…
JQ-샵투 제이쿼리( jQuery) 10 강 - jQuery stop 움직이는 효과를 중단시키기
14/35
목록
찾아주셔서 감사합니다. Since 2012