0

我有 div,thumbwrap1,它在选择图像时会改变颜色,但我很困惑的是当用户选择另一个图像时如何删除当前选定 div 的背景?

       <script type="text/javascript"> 

        function doOnChannelLoad(e) {   

    if (e.mediaList && e.mediaList.length > 0) {

      var playlistHTML = "";

      for (var i = 0; i < e.mediaList.length; i++) {
        var media = e.mediaList[i];
        if (media) {
          playlistHTML += '<div id="thumbwrap">';
          playlistHTML += '<div id="thumbwrap1"  onClick="javascript:myFunction(this);">';
          playlistHTML += '<a href="javascript:onPlaylistItemClick(\'' + media.id + '\');">';
          playlistHTML += '<img width="105"  border "1" src="' + media.thumbnailUrl + '"/ >';
           playlistHTML += '</div>';
          playlistHTML += '<div id="thumbwrap-title">' + media.title + '</div>';
          playlistHTML += '</a>';
          playlistHTML += '</div>';
        }
      }

      playlistHTML += '<br style="clear:both;" />';

      var playlistBox = document.getElementById('playlist-box').innerHTML = playlistHTML;
      drawBorder(e.id);

    }

  }

  function onPlaylistItemClick(mediaId) {

    DelvePlayer.doSetMedia(mediaId, false);

  }

  function onChannelListClick(channelId) {

    DelvePlayer.doLoadChannel(channelId);

  }  

  function drawBorder(elementId) {

    $('li').removeClass('channelSelected');
    document.getElementById(elementId).setAttribute("class", "channelSelected");

  }  

功能我的功能(divObj){

divObj.style.background="#E79F2C";
 $(this).remove(divObj);

}

谢谢。

4

0 回答 0