{"id":212,"date":"2013-01-01T01:20:30","date_gmt":"2012-12-31T19:20:30","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=212"},"modified":"2013-01-01T01:20:30","modified_gmt":"2012-12-31T19:20:30","slug":"jquery-get-value-of-div-with-custom-attribute","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=212","title":{"rendered":"JQuery &#8211; Get Value of DIV with Custom Attribute"},"content":{"rendered":"<p>I have a ProjectServer with a custom field (Project Status Slide) where users have a URL for an image.<\/p>\n<p>I needed to retrieve the URL from the custom field and display it inline on the ProjectDetails.aspx page<\/p>\n<p>&lt;div GUID=&#8221;xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx&#8221;&gt;<a href=\"http:\/\/projectserver.usace.army.mil\/PWA\/Pictures\/ANSS.png%3c\/div\">http:\/\/myserver\/PWA\/Pictures\/Slide1.png&lt;\/div<\/a>&gt;<\/p>\n<p>The source of the custom field resembles the above.<\/p>\n<p>I put a Content Editor Web Part at the bottom of the ProjectDetails.aspx page with the following script.<\/p>\n<pre>&lt;img id=\"pss\" src=\"\/PWA\/Project%20Detail%20Pages\/\" alt=\"\"\/&gt; -- Placeholder for the Slide.<\/pre>\n<pre>&lt;script src=\"\/PWA\/Project%20Detail%20Pages\/jquery.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt; -- Jquery<\/pre>\n<pre>\u00a0\u00a0&lt;script&gt;<\/pre>\n<pre>$(document).ready(function(){<\/pre>\n<pre>var myDiv = $(\"div[GUID='xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx']\"); -- Look for DIV with Custom Attribute<\/pre>\n<pre>var URL1 = $(myDiv).text(); -- Get the URL between that DIV<\/pre>\n<pre>URL1 = URL1.replace(\"http:\", \"https:\"); -- Just in case some used HTTP<\/pre>\n<pre>\/\/ alert(URL1); -- for debug<\/pre>\n<pre>\u00a0$('#pss').attr('src', URL1); - Replace my image src above with the Slide URL<\/pre>\n<pre>\u00a0});&lt;\/script&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have a ProjectServer with a custom field (Project Status Slide) where users have a URL for an image. I needed to retrieve the URL from the custom field and display it inline on the ProjectDetails.aspx page &lt;div GUID=&#8221;xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx&#8221;&gt;http:\/\/myserver\/PWA\/Pictures\/Slide1.png&lt;\/div&gt; The source of the custom field resembles the above. I put [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[40,62,85],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-div-with-custom-attribute","tag-jquery","tag-project-server"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}