Hide image generated by Javascript


I'm using the sharethis plugin to share content on social networks. For this I am making the following call:

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=YOUR_PUBLISHER_ID"></script>


<imgwidth="125" border="0" height="16" alt="Share" src="//ct1.addthis.com/static/btn/v2/lg-share-pt.gif"></img>

Is it possible to hide the image in javascript? To hide the image I'm trying as follows but it does not work:

 $('#teste2').find('img[src$="//ct1.addthis.com/static/btn/v2/lg-share-pt.gif"]').css('visibility', 'hidden');

I found this example on the net, and managed to modify it to what I wanted. But in this case I'm not getting it, I do not know if it will be the way of the generated image.


The issue is that my images appear correctly and do the sharing, but the image above is also added and I wanted to hide it.

asked by anonymous 27.02.2014 / 00:04

3 answers


I suggest doing a search for images that have the shareit domain in your url (src) and hide them.

$('.sortEleWrapper img').each(function () {
    if (this.src.split('addthis.com/static/')[1]) this.style.display = 'none';

In this case I have used .sortEleWrapper as an ancestral / parent element, but if there is a closer one, it is better. The idea is to search for all the images within this element and its descendants and hide those that have a part of src containing this string addthis.com/static/


Another idea is to put the script inside a "shield" / wrapper div and put a rule in CSS to hide images that are with #escudo img{display: none;}


27.02.2014 / 00:13

An idea would be to include the file script making use of $.getScript() to include the sharethis plugin in the page.

In this way you can be aware and know when it has been loaded, thus executing the code to locate and hide the image:

var endereco = "http://s7.addthis.com/js/250/addthis_widget.js#username=YOUR_PUBLISHER_ID";

$.getScript( endereco )
.done(function( script, textStatus ) {
    // correu bem, localizar e esconder imagem que contém X
.fail(function( jqxhr, settings, exception ) {
    // correu mal, agir em conformidade

Useful information:

27.02.2014 / 01:08

Your code is not complete.

But try to make the change through CSS.

   background: url("imagem.jpg") no-repeat;
   padding:0px 16px 0 0;
27.02.2014 / 00:17