{"id":1059,"date":"2012-07-20T08:37:45","date_gmt":"2012-07-20T08:37:45","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=1059"},"modified":"2012-07-20T08:37:45","modified_gmt":"2012-07-20T08:37:45","slug":"jquery-get-div-title-alert-div-title-using-jquery-2-ways","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-get-div-title-alert-div-title-using-jquery-2-ways\/","title":{"rendered":"jQuery Alert \/ Get DIV Title Examples"},"content":{"rendered":"<p>If you ever wanted to alert Div title using jQuery but didn&#8217;t know how to do it, then you will find this article immensely helpful as I am going to share 2 ways to <em><strong>get div title using jQuery<\/strong><\/em>. By using jQuery, get title of any div or paragraph or any other element. Read on to find out more.<!--more--><\/p>\n<h2>How to use jQuery to Get DIV Title \/ Alert DIV Title<\/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=1059\" 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>I am going to show you 2 ways to <em><strong>alert \/ get\u00a0div title using jQuery<\/strong><\/em>. The difference in these two methods is minor and you will be able to understand them very easily. The differences exist\u00a0primarily due to the version change in jQuery. I am going to show you how to do this by using an easy to follow example. Assume that we have a div with ID &#8220;my_div&#8221; and it has the title &#8220;My Div title&#8221;. Our aim is to get div title when &#8220;Show DIV title&#8221; button is clicked.<\/p>\n<h3>Common HTML Source Code for the following examples:<\/h3>\n<pre class=\"lang:xhtml decode:true\">&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;Alert DIV Title using 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;\n\n&lt;div id=\"my_div\" class=\"my_class\" title=\"My Div title\"&gt;This is my div.&lt;\/div&gt;\n\n&lt;input type=\"submit\" name=\"show_title\" id=\"show_title\" value=\"Show DIV title\" \/&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<h3>Example 1: How to get Div Title when\u00a0jQuery version &lt; 1.6<\/h3>\n<pre class=\"lang:js decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\n$(document).ready(function() {\n\n$('#show_title').click(function(){\n\n\/\/ Get \/ Alert Div Title when jQuery version &lt; 1.6\nalert( $('#my_div').attr(\"title\") );\n});\n\n});\n\n&lt;\/script&gt;<\/pre>\n<h3>Example 2:\u00a0How to get Div Title when\u00a0jQuery version &gt; 1.6<\/h3>\n<pre class=\"lang:js decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\n$(document).ready(function() {\n\n$('#show_title').click(function(){\n\n\/\/ Alert \/ Get Div Title when jQuery version &gt; 1.6\nalert( $('#my_div').prop(\"title\") );\n\n});\n\n});\n\n&lt;\/script&gt;<\/pre>\n<p>So <strong>if you are using jQuery version &gt; 1.6, I strongly suggest you to go with Example 2<\/strong> shown above for best\u00a0practices &amp; for better future compatibility .<\/p>\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=1059\" 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<h5>Your turn!<\/h5>\n<p>Do you know of any other ways to use <em><strong>jQuery to\u00a0<\/strong><strong>alert \/ get Div title<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you ever wanted to alert Div title using jQuery but didn&#8217;t know how to do it, then you will find this article immensely helpful as I am going to share 2 ways to get div title using jQuery. By using jQuery, get title of any div or paragraph or any other element. Read on [&hellip;]<\/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,106,41],"class_list":["post-1059","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-get-title","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-h5","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1059","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=1059"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1059\/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=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}