jQuery의 현재 웹 페이지에 얼마나 많은 특정 종류의 요소가 존재하는지 아는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/1811867

  •  06-07-2019
  •  | 
  •  

문제

많이있다 <label name="delQ" style="cursor:pointer">Remove</label>웹 페이지의 요소; 요소는 동적으로 생성됩니다. 현재 웹 페이지에 얼마나 많은 "delq"가 존재하는지 결정하는 방법은 무엇입니까?

$('[name="delQ"]').live('click', function() {
//Get the number of name="delQ" in the current web page.
});

jQuery에서 어떻게 하는가?

도움이 되었습니까?

해결책

$('label[name="delQ"]').length;

length

Returns the number of elements in the jQuery object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top