Image repeating

Asked

Viewed 71 times

2

I implemented a code on my site, this is a retractable chatbox. It has two images, one of these is to open the chatbox and the other to close. However, when you open the chatbox, it gets two images of "Closed" as you can see below:

inserir a descrição da imagem aqui

I’d like you to just stand next to me.

Code:

jQuery(document).ready(function(){

    s="jQuery('#chatboxpop').animate({width:'toggle'},350); jQuery('#chatboxopen,#chatboxclose').toggle();";
    jQuery('body').prepend('<div style="overflow: visible; position: fixed; bottom: 30px; height: 400px; right: 0px; z-index:1000;"><iframe src="http://bloodypalacerpg.chatango.com/" id="chatboxpop" scrolling="yes" style="height: 300px; border: 2px solid #000000; -webkit-border-radius: 3px; float: right; overflow-x: visible; overflow-y: visible; display: none; width:600px" marginwidth="0" marginheight="0" frameborder="0"></iframe><div onclick="'+s+'" style="margin-top: 10px; cursor :pointer; float:left"><img src="http://i34.servimg.com/u/f34/16/04/51/75/open10.png" id="chatboxopen" style="display: inline; "><img src="http://i34.servimg.com/u/f34/16/04/51/75/close10.png" id="chatboxclose" style="cursor: pointer; display: none; "></div></div>')

});
  • Checks if there is only one <body>.

  • Apparently two close image is being created one when the chat is closed and the other when opening, what you could see is inspecting the html with F12 and check if this is happening, if it is you will have to arrange to open the chat give one . Hide() in the image on the screen.

  • Yes, there’s only one.

  • Rodrigo, I’ve already checked in inspecting element, there’s only one code.

1 answer

2


Instead of using .prepend() or .append() try to use .html() this will replace the elements.

For example: $('#' + div).html(valor);

Another example:

$('#' + div).html(<span style="opacity:0;">Valor</span>);
$('#' + div span).animate({opacity:1},slow);
  • 1

    Right! It worked. ^^

  • Need something, call it! Welcome to stackoverflow.

  • Thank you. :D ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.