- jQuery - Home
- jQuery - Roadmap
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
jQuery [attribute!=value] Selector
The [attribute!=value] selector in jQuery is used to select elements that do not have a specific attribute value. In other words, It filters elements based on attributes that do not match a specified value.
Syntax
Following is the syntax of [attribute!=value] Selector in jQuery −
$("[attribute!='value']")
Parameters
Here is the description of the above syntax −
- attribute: The attribute of the HTML element that you are checking.
- value: The value that the attribute should not be equal to.
Example 1
In the following example, we are using the jQuery [attribute!=value] Selector to select the elements where the 'data-type' attribute is not 'fruit' −
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div[data-type!='fruit']").css("background-color", "yellow");
});
</script>
</head>
<body>
<div data-type="fruit">Apple</div>
<div data-type="vegetable">Carrot</div>
<div data-type="fruit">Banana</div>
<div data-type="vegetable">Broccoli</div>
</body>
</html>
The selected elements will be highlighted with yellow background color.
Example 2
Here, we are disabling the buttons except those with type='submit −
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
// Disable all buttons except those with type='submit'
$("button[type!='submit']").prop("disabled", true);
});
</script>
</head>
<body>
<button type="button">Click Me</button>
<button type="reset">Reset</button>
<button type="submit">Submit</button>
</body>
</html>
After executing the above program, the selected button will be disabled.
jquery_ref_selectors.htm
Advertisements