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

[Property] JQ - length 속성 ★ - 객체의 요소개수 (= length속성 = 렝스속성) ※ 입력 내용 일정 길이 이상 시, 포커스 자동 이동.

목차

  1. length 예제 - li 요소 개수
  2. length 정의
  3. length 구문
  4. length 예제 - 입력 내용 일정 길이 이상 시, 포커스 자동 이동

 

length 예제 - li 요소 개수

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("button").click(function(){

    alert($("li").length);

  });

});

</script>


<button>요소 개수?</button>


<ul>

  <li>홈짱닷컴</li>

  <li>Homzzang.com</li>

  <li>홈페이지제작 + 서버관리</li>

</ul>

 

결과보기

결과값: 3

 

length 정의

 

jQuery 객체의 요소 개수.

 



※ 주의.

JQ 3.0 이상 경우, size() 폐기완료. length 속성으로 대체.

 

 

length 구문

 

$(selector).length

 

※ selector : 선택자 

 

length 예제 - 입력 내용 일정 길이 이상 시, 포커스 자동 이동

 

<input type="tel" id="counsel_tel1" name="counsel_tel1" maxlength="3" class="is3" placeholder="연락처">

 

<script> 

$(function () {

    $('input[name="counsel_tel1"]').keyup(function (e) {

        var thisLen = $(this).val().length;

        if (thisLen >= 3) {

            $('input[name="counsel_tel2"]').focus();

        }

    });

    ....

});

</script>

 

트리플 님 (201102) https://sir.kr/g5_skin/40699


방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
Property JQ - context 속성 - (※ JQ1.8폐기예고, JQ3.0 폐기완료)
Property JQ - jquery 속성 - 제이쿼리버전번호 (= jQuery버전번호 = JQ버전번호)
Property JQ - jQuery.fx.interval 속성 - 애니메이션 점화빈도를 밀리초단위로 변경
Property JQ - jQuery.fx.off 속성 - 애니메이션 비활성화/활성화
Property JQ - jQuery.support 속성 - 브라우저 기능/버그 표시 속성모음 (jQuery 내부용)
Property JQ - length 속성 ★ - 객체의 요소개수 (= length속성 = 렝스속성) ※ 입력 내용 일정 길…
목록
찾아주셔서 감사합니다. Since 2012