Jump to content
Fórum Script Brasil
  • 0

Drag and Drop


brunomartins

Question

Iae galera...

Pessoal vocês poderiam me ajudar...

Tem como colocar uma imagem em uma div (quadrado) e essa div mudar de cor, e quando eu tirasse essa imagem essa div ficaria de cor diferente?

Eu so consegui fazer com q ela ficasse de uma cor quando eu coloquei a imagem, mas quando eu tiro ela fica da mesma cor...

Se vocês puderem me ajudar ficaria muito agradecido...

ta aki o codigo em html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Cickweb | Drag n Drop</title>
<script src="js1.js" type="text/javascript"></script>
<link rel ="stylesheet" href="css.css">
<!--<script type="text/javascript" src="jquery.js"></script>-->
<meta name="Robots" content="noindex,nofollow" />
</head>
<body>
<div id="mainContainer">
<div id="tabs1" class="tab-content">
<div id="words">
<div id="dropContent">
<div class="dragableBox" id="box1"><img src="02.jpg" width="30px"></div>
<div class="dragableBox" id="box2"><img src="02.jpg" width="30px"></div>
</div><!-- /dropContent -->
</div><!-- /words -->
<div id="pictures">
<div id="box106" class="dragableBoxRight"></div>
<div id="box101" class="dragableBoxRight"></div>
<div id="box107" class="dragableBoxRight"></div>
<div id="box109" class="dragableBoxRight"></div>
<div id="box104" class="dragableBoxRight"></div>
<div id="box108" class="dragableBoxRight"></div>
<div id="box102" class="dragableBoxRight"></div>
<div id="box105" class="dragableBoxRight"></div>
<div id="box103" class="dragableBoxRight"></div>
</div>
<div class="clear"></div>
<div class="konaBody"></div>
</div>
<div id="tabs2" class="tab-content">
</div>
<script type="text/javascript">// Custom drop action for the picture boxes
var dragDropObj = new DHTMLgoodies_dragDrop();
dragDropObj.addSource('box1',true);
dragDropObj.addSource('box2',true);
dragDropObj.addTarget('box101','dropItems');
dragDropObj.addTarget('box102','dropItems');
dragDropObj.addTarget('box103','dropItems');
dragDropObj.addTarget('box104','dropItems');
dragDropObj.addTarget('box105','dropItems');
dragDropObj.addTarget('box106','dropItems');
dragDropObj.addTarget('box107','dropItems');
dragDropObj.addTarget('box108','dropItems');
dragDropObj.addTarget('box109','dropItems');
dragDropObj.addTarget('words','dropItems');
dragDropObj.init();
</script>
<script>
function dropItems(idOfDraggedItem,targetId){
var targetObj = document.getElementById(targetId);
var subDivs = targetObj.getElementsByTagName('DIV');
if(subDivs.length>0 && targetId!='words')return
var sourceObj = document.getElementById(idOfDraggedItem);
targetObj.appendChild(sourceObj);
targetObj.style.backgroundColor='#C0C2C4';
}
</script>
</body>
</html>
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...