{"id":767,"date":"2012-06-05T06:42:13","date_gmt":"2012-06-05T06:42:13","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=767"},"modified":"2012-06-05T06:42:13","modified_gmt":"2012-06-05T06:42:13","slug":"jquery-select-title-select-title-of-any-element-using-jquery","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-select-title-select-title-of-any-element-using-jquery\/","title":{"rendered":"jQuery Select Title Of Any Element Examples"},"content":{"rendered":"<p>Wondering how to <em><strong>select title of a html element using jQuery<\/strong><\/em>? In this article, I am going to share a very simple way to get the title of any html element, be it a\u00a0div, hyperlink, image, or any other html element.<!--more--><\/p>\n<h2>How to Select Title of any element using jQuery &#8211; Examples<\/h2>\n<h3>Example 1: Select Title of a DIV using jQuery<\/h3>\n<p>Let&#8217;s assume that we have a div with ID &#8220;my_div&#8221;, it has some content and we want to get it&#8217;s title. Here&#8217;s how you can do it:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\n$(document).ready(function() {\n\nvar title = $(\"#my_div\").attr('title');\n\nalert(title);\n\n});\n\n&lt;\/script&gt;<\/pre>\n<p>The code above simply grabs the title of the &#8220;my_div&#8221; div when the page loads and alerts it out. You can use the same procedure to get title of images, hyperlinks, etc. Examples below:<\/p>\n<h3>Example 2: Select Title of an image using jQuery<\/h3>\n<pre class=\"lang:xhtml decode:true\">\/\/HTML\n\n&lt;img src=\"somesrc\" id=\"my_image\" width=\"100\" height=\"100\" \/&gt;\n\n\/\/jQuery code\n\nvar img_title = $(\"#my_image\").attr('title');\n\nalert(img_title);<\/pre>\n<h3>Example 3: Select Title of a hyperlink using jQuery<\/h3>\n<pre class=\"lang:xhtml decode:true\">\/\/HTML\n\n&lt;a href=\"#\" id=\"my_link\"&gt;Click here to navigate&lt;\/a&gt;\n\n\/\/jQuery code\n\nvar hyperlink_title = $(\"#my_link\").attr('title');\n\nalert(hyperlink_title);<\/pre>\n<h5>Very simple, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to <em><strong>select title of html elements using jQuery<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wondering how to select title of a html element using jQuery? In this article, I am going to share a very simple way to get the title of any html element, be it a\u00a0div, hyperlink, image, or any other html element.<\/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":[21],"tags":[],"class_list":["post-767","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-cn","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/767","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=767"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/767\/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=767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}