728x90
SMALL
jQuery
.not()
.not () selects the selected elements except for a specific selector.
grammar
.not( selector )
for example
$( 'p' ).not( 'p.abc' ).css( 'color', 'green');
Select one that does not have abc in the p element as a class value.
example
Clicking the button replaces the contents of the li element, which does not have ip as a class value, in red.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$( document ).ready( function() {
$( 'button' ).click( function() {
$( 'li' ).not( 'li.ip' ).css( 'color', 'red');
} );
} );
</script>
</head>
<body>
<button>Click</button>
<ul>
<li>Lorem</li>
<li class="ip">Ipsum</li>
<li>Dolor</li>
</ul>
</body>
</html>
728x90
LIST
'jQuery' 카테고리의 다른 글
[jQuery] jQuery / jQuery.noConflict () / Prevent conflicts with other libraries, different versions of jQuery (0) | 2022.07.28 |
---|---|
[jQuery] How to link and use HTML documents (0) | 2022.07.28 |
[jQuery] Method / .clone ()-Method to clone selected element (0) | 2022.07.27 |
[jQuery] Select all checkboxes, create deselect all (0) | 2022.07.25 |
[jQuery] Create a link that moves smoothly to the top (0) | 2022.07.25 |