> 웹 프론트엔드 > JS 튜토리얼 > jQuery에서 end 메소드 사용

jQuery에서 end 메소드 사용

巴扎黑
풀어 주다: 2017-06-24 11:14:51
원래의
2378명이 탐색했습니다.

결과 집합에 대해 찾기, 필터링 및 기타 방법을 사용하면 결과 집합이 변경됩니다.

원래 결과 집합을 변경하는 이 메서드를 파괴적 jQuery 메서드

jQuery 요리책의 정의는 다음과 같습니다.

파괴 작업은 일치하는 jQuery 요소 집합을 변경하는 작업입니다. 또는 add(), andSelf(), children(), closes(), filter(), find(), map(), next(), nextAll(), not(), parent(), parent(), prev(), prevAll(), siblings(), Slice(), clone(),appendTo(), prependTo(), insertBefore<a href="http://www.php.cn/wiki/135.html" target="_blank">(), insertAfter(), replacementAll()</a>. 구체적인 사용법은 다음과 같습니다

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
</head>
<body>
	<p>Text</p>
	<p class="middle">Middle <span>Text</span></p>
	<p>Text</p>
<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript">
	alert($(&#39;p&#39;).filter(&#39;.middle&#39;).length); // alerts 1
	alert($(&#39;p&#39;).filter(&#39;.middle&#39;).end().length); // alerts 3
	alert($(&#39;p&#39;).filter(&#39;.middle&#39;).find(&#39;span&#39;).end().end().length); // alerts 3
</script>
</body>
</html>
로그인 후 복사
add(), andSelf(), children(), closes(), filter(), find(), map(), next(), nextAll(), not(), parent(), parents(), prev(), prevAll(), siblings(), slice(), clone(), appendTo(), prependTo(), insert<a href="http://www.php.cn/java/java-Before.html" target="_blank">Before</a>(), insertAfter(), replaceAll()

具体用法如下

rrreee

当对$('p')的结果执行filter('.middle')时,只有<p class="middle">Middle <span>Text</span></p>符合结果。

继续对上述操作执行end(),则filter()$('p')의 결과에 대해 filter('.middle')를 실행할 때, <p class="middle">Middle <span>Text</span></p>가 결과와 일치합니다.

🎜위 작업에 대해 end()를 계속 실행하면 filter()의 효과가 취소되고 결과 집합에 3개의

🎜이 포함됩니다.

위 내용은 jQuery에서 end 메소드 사용의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿