1. Description
해당 속성을 가지고 있지 않은 Element, 또는 해당 속성을 가지고 있지만 속성값과 일치하지 않는 Element들을 찾는다.
2. Example
#1버튼을 클릭할 때마다 value속성이 'love story'로 되어 있지 않은 Element들을 찾아 폰트 크기를 1씩 증가시킨다.
My Stories
[HTML Code]
[//HTML Code]
3. Code
더보기
<!-- ---------------------------------------------------------
--
-- Author: 1q74.tistory.com
--
--------------------------------------------------------- -->
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>[1q74.tistory.com] javascript/jquery/selector/attribute-not-equals</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
</head>
<body>
<div name="_1q74-example-root">
<div name="_1q74-example-1">
<h4>My Stories</h4>
<li value="tstory">TStory</li>
<li value="story challenge">Story Challenge</li>
<li value="ustory">UStory</li>
<li value="wstory">WStory</li>
<li value="story maker">Story Maker</li>
<li value="love story" style="color:#567452">Love Story</li>
</div>
<div name="_1q74-example-bottom">
<br/>
<button name="btn-execute">#1. li[value!='love story']")</button>
</div>
</div>
<hr/>
<h5>[HTML Code]</h5>
<div name="_1q74-source">
</div>
<h5>[//HTML Code]</h5>
<script>
const btnExecute = $("[name='btn-execute']");
const notLoveStory = $("li[value!='love story']");
btnExecute.click(function() {
let styles = {
fontSize: parseInt(notLoveStory.css("font-size"), 10) + 1
};
notLoveStory.css(styles);
});
// ------------------------------------------------------
// [HTML Code]
// ------------------------------------------------------
var textSource = $("[name='_1q74-source']");
var exampleHtml = $("[name='_1q74-example-root']").html();
var specialCharLines = textSource.text(exampleHtml).html().split("\n");
textSource.html(specialCharLines.join("<br/>").replaceAll("\t", " "));
// ------------------------------------------------------
</script>
<style>
[name|='_1q74-example'] li {
list-style-type: none;
}
[name|="_1q74-example"] button
,[name="_1q74-source"] button {
background: lightgray;
border: 5px outset;
min-height: 30px;
}
[name|="_1q74-example"] button:active
,[name="_1q74-source"] button:active {
border: 2px inset;
min-height: 30px;
}
</style>
</body>
</html>
4. File
5. Reference
https://api.jquery.com/attribute-not-equal-selector/
'JavaScript > jQuery' 카테고리의 다른 글
【jQuery/Selector #10】:button (0) | 2023.02.21 |
---|---|
【jQuery/Selector #9】Attribute Starts With Selector [name^=”value”] (0) | 2023.02.21 |
【jQuery/Selector #7】Attribute Equals Selector [name=”value”] (0) | 2023.02.21 |
【jQuery/Selector #6】Attribute Ends With Selector [name$=”value”] (0) | 2023.02.21 |
【jQuery/Selector #5】Attribute Contains Word Selector [name~=”value”] (0) | 2023.02.21 |