{"id":3342,"date":"2018-10-27T06:45:09","date_gmt":"2018-10-27T06:45:09","guid":{"rendered":"https:\/\/tutorialsclass.com\/?p=3342"},"modified":"2022-06-11T13:08:08","modified_gmt":"2022-06-11T13:08:08","slug":"jquery-selectors","status":"publish","type":"post","link":"https:\/\/tutorialsclass.com\/jquery-selectors\/","title":{"rendered":"jQuery Selectors"},"content":{"rendered":"\n<p>jQuery selectors are widely used for matching a set of elements in the HTML document.<\/p>\n\n\n\n<p>jQuery selector enables you to select and manipulate HTML element(s). Elements or Tags can be selected based on their name, id, classes and attributes.<\/p>\n\n\n\n<p>All jQuery selectors start with a dollar sign and parentheses: $().<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">The element Selector<\/h3>\n\n\n\n<p>The jQuery element selector find HTML elements based on their tag names.<br>For example: $(\u2018h2\u2019) selects all headings&nbsp;<code>&lt;h2&gt;<\/code>&nbsp;in the document.<\/p>\n\n\n\n<p><strong>Example:<\/strong><br>In this example, jQuery element selector hides&nbsp;<code>&lt;h2&gt;<\/code>&nbsp;elements.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>$(document).ready(function() {\n    $(\"h2\").hide();\n});<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The #id Selector<\/h3>\n\n\n\n<p>The jQuery #id selector finds HTML element based on id attribute. It is useful for finding single specific element because HTML page can have single unique id assigned to any element.<\/p>\n\n\n\n<p>To find an HTML element with specific ID, write a hash (#) character followed by the id of the HTML element.<\/p>\n\n\n\n<p><strong>Example:<\/strong><br>In this example, the elements with id=\u2019main-content\u2019 will be hidden.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>$(document).ready(function() {\n    $(\"#main-content\").hide();\n});<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The .class Selector<\/h3>\n\n\n\n<p>The jQuery class selector finds elements with a given class name. Class selectors can select multiple elements having the same class name.<\/p>\n\n\n\n<p>To find elements using Class selector, write a dot or period (.) character, followed by the class of the HTML element.<\/p>\n\n\n\n<p><strong>Example:<\/strong><br>In this example, the elements with class=\u201dmyclass\u201d will be hidden.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>$(document).ready(function() {\n    $(\".myclass\").hide();\n});<\/code><\/pre>\n\n\n\n<script async src=\"\/\/jsfiddle.net\/deepakrajpal\/sgznggw3\/42\/embed\/\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>jQuery selectors are widely used for matching a set of elements in the HTML document. jQuery selector enables you to select and manipulate HTML element(s). Elements or Tags can be selected based&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"keywords":[],"class_list":["post-3342","post","type-post","status-publish","format-standard","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>jQuery Selectors - Class &amp; ID Selector with example | Tutorials Class<\/title>\n<meta name=\"description\" content=\"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorialsclass.com\/jquery-selectors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery Selectors - Class &amp; ID Selector with example | Tutorials Class\" \/>\n<meta property=\"og:description\" content=\"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorialsclass.com\/jquery-selectors\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorials Class\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tutorialsclass\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-27T06:45:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-11T13:08:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Tutorials Class\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:site\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tutorials Class\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/\"},\"author\":{\"name\":\"Tutorials Class\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\"},\"headline\":\"jQuery Selectors\",\"datePublished\":\"2018-10-27T06:45:09+00:00\",\"dateModified\":\"2022-06-11T13:08:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/\"},\"wordCount\":212,\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"articleSection\":[\"jQuery Tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/\",\"url\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/\",\"name\":\"jQuery Selectors - Class & ID Selector with example | Tutorials Class\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/#website\"},\"datePublished\":\"2018-10-27T06:45:09+00:00\",\"dateModified\":\"2022-06-11T13:08:08+00:00\",\"description\":\"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorialsclass.com\/jquery-selectors\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorialsclass.com\/jquery-selectors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorialsclass.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery Tutorial\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jQuery Selectors\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorialsclass.com\/#website\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"name\":\"Tutorials Class\",\"description\":\"Online Tutorials for Beginners\",\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorialsclass.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tutorialsclass.com\/#organization\",\"name\":\"Tutorials Class\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"contentUrl\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"width\":442,\"height\":94,\"caption\":\"Tutorials Class\"},\"image\":{\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tutorialsclass\",\"https:\/\/x.com\/TutorialsClass\",\"https:\/\/in.pinterest.com\/merientinfotech\/boards\/\",\"https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\",\"name\":\"Tutorials Class\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"caption\":\"Tutorials Class\"},\"sameAs\":[\"tcadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery Selectors - Class & ID Selector with example | Tutorials Class","description":"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorialsclass.com\/jquery-selectors\/","og_locale":"en_US","og_type":"article","og_title":"jQuery Selectors - Class & ID Selector with example | Tutorials Class","og_description":"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.","og_url":"https:\/\/tutorialsclass.com\/jquery-selectors\/","og_site_name":"Tutorials Class","article_publisher":"https:\/\/www.facebook.com\/tutorialsclass","article_published_time":"2018-10-27T06:45:09+00:00","article_modified_time":"2022-06-11T13:08:08+00:00","og_image":[{"width":600,"height":600,"url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png","type":"image\/png"}],"author":"Tutorials Class","twitter_card":"summary_large_image","twitter_creator":"@TutorialsClass","twitter_site":"@TutorialsClass","twitter_misc":{"Written by":"Tutorials Class","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/#article","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/"},"author":{"name":"Tutorials Class","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e"},"headline":"jQuery Selectors","datePublished":"2018-10-27T06:45:09+00:00","dateModified":"2022-06-11T13:08:08+00:00","mainEntityOfPage":{"@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/"},"wordCount":212,"publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"articleSection":["jQuery Tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/","url":"https:\/\/tutorialsclass.com\/jquery-selectors\/","name":"jQuery Selectors - Class & ID Selector with example | Tutorials Class","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/#website"},"datePublished":"2018-10-27T06:45:09+00:00","dateModified":"2022-06-11T13:08:08+00:00","description":"jQuery selectors are used for matching a set of elements in a web page. jQuery selector finds HTML element based on their name, id, classes and attributes.","breadcrumb":{"@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorialsclass.com\/jquery-selectors\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorialsclass.com\/jquery-selectors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorialsclass.com\/"},{"@type":"ListItem","position":2,"name":"Learn","item":"https:\/\/tutorialsclass.com\/learn\/"},{"@type":"ListItem","position":3,"name":"jQuery Tutorial","item":"https:\/\/tutorialsclass.com\/learn\/jquery\/"},{"@type":"ListItem","position":4,"name":"jQuery Selectors"}]},{"@type":"WebSite","@id":"https:\/\/tutorialsclass.com\/#website","url":"https:\/\/tutorialsclass.com\/","name":"Tutorials Class","description":"Online Tutorials for Beginners","publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorialsclass.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tutorialsclass.com\/#organization","name":"Tutorials Class","url":"https:\/\/tutorialsclass.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/","url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","contentUrl":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","width":442,"height":94,"caption":"Tutorials Class"},"image":{"@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tutorialsclass","https:\/\/x.com\/TutorialsClass","https:\/\/in.pinterest.com\/merientinfotech\/boards\/","https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA"]},{"@type":"Person","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e","name":"Tutorials Class","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","caption":"Tutorials Class"},"sameAs":["tcadmin"]}]}},"_links":{"self":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/3342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/comments?post=3342"}],"version-history":[{"count":5,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/3342\/revisions"}],"predecessor-version":[{"id":7424,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/3342\/revisions\/7424"}],"wp:attachment":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/media?parent=3342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/categories?post=3342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/tags?post=3342"},{"taxonomy":"keywords","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/keywords?post=3342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}