snipt

Ctrl+h for KB shortcuts

Text only

jquery image inserted into div with class

1
2
3
4
5
6
7
8
9
$(document).ready(function(){

    var gdspLogo = 'http://yodleresources.net/National_NS/GentleDental/images/gdsplogo.png';
    var ddLogo = 'http://yodleresources.net/National_NS/GentleDental/images/ddlogo.png';

    $('.gdspLogo').html('<img src="' + gdspLogo + '" alt="Gentle Dental Smile Plan" />');
    $('.ddLogo').html('<img src="' + ddLogo + '" alt="Dedicated Dental" />');

});

Description

Declares two variables with links to images and then inserts the images into a div. Useful for inserting full sized images on the home page so they don't get stripped out of the asw.
https://snipt.net/embed/a5c212f47e968505bd48d5cf4babdc23/
/raw/a5c212f47e968505bd48d5cf4babdc23/
a5c212f47e968505bd48d5cf4babdc23
text
Text only
10
2019-06-18T00:34:58
True
False
False
Feb 12, 2016 at 02:42 PM
/api/public/snipt/144126/
jquery-image-inserted-into-div-with-class
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a> <a href="#L-9">9</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$(document).ready(function(){ </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> var gdspLogo = &#39;http://yodleresources.net/National_NS/GentleDental/images/gdsplogo.png&#39;; </span><span id="L-4"><a name="L-4"></a> var ddLogo = &#39;http://yodleresources.net/National_NS/GentleDental/images/ddlogo.png&#39;; </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a> $(&#39;.gdspLogo&#39;).html(&#39;&lt;img src=&quot;&#39; + gdspLogo + &#39;&quot; alt=&quot;Gentle Dental Smile Plan&quot; /&gt;&#39;); </span><span id="L-7"><a name="L-7"></a> $(&#39;.ddLogo&#39;).html(&#39;&lt;img src=&quot;&#39; + ddLogo + &#39;&quot; alt=&quot;Dedicated Dental&quot; /&gt;&#39;); </span><span id="L-8"><a name="L-8"></a> </span><span id="L-9"><a name="L-9"></a>}); </span></pre></div> </td></tr></table>
"content replacement", jquery
--- 
+++ 
@@ -0,0 +1,9 @@
+$(document).ready(function(){
+
+    var gdspLogo = 'http://yodleresources.net/National_NS/GentleDental/images/gdsplogo.png';
+    var ddLogo = 'http://yodleresources.net/National_NS/GentleDental/images/ddlogo.png';
+
+    $('.gdspLogo').html('<img src="' + gdspLogo + '" alt="Gentle Dental Smile Plan" />');
+    $('.ddLogo').html('<img src="' + ddLogo + '" alt="Dedicated Dental" />');
+
+});