{"id":1940,"date":"2012-12-18T21:36:03","date_gmt":"2012-12-18T21:36:03","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=1940"},"modified":"2012-12-18T21:36:03","modified_gmt":"2012-12-18T21:36:03","slug":"jquery-not-using-not-in-jquery-not-selector-examples","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-not-using-not-in-jquery-not-selector-examples\/","title":{"rendered":"jQuery :not() Selector Examples"},"content":{"rendered":"<p>Have you ever come across the <em><strong>jQuery not selector<\/strong><\/em>? If yes, did you wonder how \u00a0&amp; why it&#8217;s used? In this article, I am going to show by means of a simple to follow example on how to use the :<strong>not() selector in jQuery<\/strong>. So read on to find out more.<!--more--><\/p>\n<h2>How to use the jQuery not() Selector<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1940\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>For the sake of the example, let&#8217;s assume that we have few checkboxes and we would like to alert the index &amp; the value of the &#8220;not&#8221; checked checkboxes or the &#8220;unchecked&#8221; checkboxes when a button is clicked.<\/p>\n<p><strong>Example: HTML + jQuery source code for using <strong>\u00a0jQuery\u00a0<\/strong>.not() selector<\/strong><\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;Examples of using the .not() Selector in jQuery&lt;\/title&gt;\n&lt;script type=\"text\/javascript\" src=\"js\/jquery-1.8.2.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\nHit the button below to alert the checkboxes that were \"not\" checked :&lt;br&gt;\n\n&lt;form name=\"form1\" method=\"post\" action=\"\"&gt;\n&lt;p&gt;\n&lt;label&gt;\n&lt;input type=\"checkbox\" name=\"fruits\" value=\"apple\" id=\"fruits_0\"&gt;\nApple&lt;\/label&gt;\n&lt;br&gt;\n&lt;label&gt;\n&lt;input type=\"checkbox\" name=\"fruits\" value=\"mango\" id=\"fruits_1\"&gt;\nMango&lt;\/label&gt;\n&lt;br&gt;\n&lt;label&gt;\n&lt;input type=\"checkbox\" name=\"fruits\" value=\"grapes\" id=\"fruits_2\"&gt;\nGrapes&lt;\/label&gt;\n&lt;br&gt;\n&lt;\/p&gt;\n&lt;input type=\"submit\" name=\"sbt_alert\" id=\"sbt_alert\" value=\"Alert &amp;quot;not&amp;quot; checked checkboxes\"&gt;\n&lt;\/form&gt;\n&lt;script type=\"text\/javascript\" language=\"javascript\" &gt;\n\n$(document).ready(function(){\n\n$('#sbt_alert').on(\"click\", function(){\n$('input[name=\"fruits\"]:not(:checked)').each(function(index) {\nalert(index + ': ' + $(this).text() + $(this).val() );\n});\n\nreturn false;\n\n});\n\n});\n\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1940\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p><strong>That&#8217;s it!<\/strong><\/p>\n<p>Do you know of any other ways to use the<strong>\u00a0 jQuery not selector<\/strong>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever come across the jQuery not selector? If yes, did you wonder how \u00a0&amp; why it&#8217;s used? In this article, I am going to show by means of a simple to follow example on how to use the :not() selector in jQuery. So read on to find out more.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[42,41],"class_list":["post-1940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-demos-2","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-vi","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=1940"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1940\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=1940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=1940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=1940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}