How to find all links with an hreflang attribute using jQuery ? Last Updated : 06 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn to find all links with a hreflang attribute. The hreflang is an attribute that tells search engines the relationship between pages in different languages on your website. To find all links with an hreflang attribute using jQuery, you can use the attribute selector $('[hreflang]'). This will select all elements that have the hreflang attribute defined. To specifically select only <a> elements with the hreflang attribute, you can use the tag selector in combination with the attribute selector: $('a[hreflang]'). You can use this attribute in the following three ways. As a link in the HTML head of the page(<head>).In the HTTP header (example PDFs)On the XML sitemap You can find all links with an hreflang attribute on your page using the attributeContainsPrefix selector. attributeContainsPrefix selector: This selector is used to select elements that have the specified attribute with a value either equal to a given string or starting with that string. Syntax: jQuery( "[attribute|='value']" ) $( "a[hreflang|='en']" ) Example 1: In the following examples, we first find the hreflang and then highlight it using CSS properties. The hreflang attribute with a value 'en' gets highlighted with the red dotted border. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <style> a { display: inline-block; } </style> <script src= "https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body> <h2 style="color:green">GeeksforGeeks</h2> <a href="example.html" hreflang="en">GFG</a> <a href="example.html" hreflang="en-UK"> Computer Science </a> <a href="example.html" hreflang="english"> will not be outlined </a> <script> $("a[hreflang|='en']") .css("border", "3px dotted red"); </script> </body> </html> Output: href lang = en Example 2: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <style> a { display: inline-block; } </style> <script src= "https://code.jquery.com/jquery-3.5.0.js"></script> </head> <body> <h2 style="color:green">GeeksforGeeks</h2> <a href="example.html" hreflang="en">Database</a> <a href="example.html" hreflang="en-UK"> Computer Networks </a> <a href="example.html" hreflang="english"> will not be outlined </a> <script> $("a[hreflang|='en']") .css("border", "3px solid green"); </script> </body> </html> Output: hreflag=en image2 Comment More infoAdvertise with us Next Article How to find element with specific ID using jQuery ? P pall58183 Follow Improve Article Tags : Web Technologies JQuery Web technologies HTML-Tags CSS-Properties jQuery-Selectors jQuery-Questions jQuery +4 More Similar Reads How to change href attribute of a hyperlink using jQuery ? Changing the href attribute of a hyperlink using jQuery refers to the process of modifying the URL a link directs to without altering the HTML manually. This capability is useful for creating dynamic web applications where link destinations need to change based on user interactions or other conditio 2 min read How to find element with specific ID using jQuery ? The question is to determine whether an element with a specific id exists or not using JQuery. jQuery on() Method: This method adds one or more event handlers for the selected elements and child elements.Syntax: $(selector).on(event, childSelector, data, function, map)Parameters: event: It is requir 3 min read How to find inputs with an attribute name starting with specific letter or text using jQuery? In this article, we will learn to find input with an attribute name starting with a specific letter or text. This task is implemented using attributeStartWith selector. attributeStartWith selector: This selector selects elements that have the specified attribute with a value beginning exactly with a 1 min read How to find all checkbox inputs using jQuery ? The task is to find all the checkbox input using jQuery. Checkboxes are the square boxes that are ticked when activated, and it is used to select one or more number of choices. Method and Selectors used: :checkbox: This selector is used to select the input element with type = checkbox. .wrap(): This 2 min read How to find an element by text using jQuery ? We will learn how to find an element using jQuery's API. This article requires some knowledge of HTML, CSS, JavaScript, Bootstrap, and jQuery. The elements can be selected based on whether they contain the string we want to find. This can be done using the jQuery contains selector to select elements 2 min read HTML <link> hreflang Attribute HTML <link> hreflang attribute specifies the language of the linked resource. It helps search engines understand the language targeting of a document. Without the href attribute, there is no use of this attribute in the link element. HTML link hreflang Attribute Syntax:<link hreflang="langa 2 min read Like