2012-01-20 7 views
0

私はonmouseoverイベントをイメージに添付しています。 mouseoverイベントはdivを作成し、画像が配置されたのと同じ位置に追加する必要があります。 divはフローティングメニューdivとして使用されます。私は座標を得ることができますが、何らかの理由でdivを文書に追加すると、divをどこにでも見ることができません。MouseOverイベントと動的メニュー部を作成するjQueryを使用する

$(actionImage).mouseover(function(e) { 

      // get the coordinates 
      var x = e.pageX - this.offsetLeft; 
      var y = e.pageY - this.offsetTop; 

      var menuDiv = createMenuDiv(); 

      $(menuDiv).css(
       { 
        position:"absolute", 
        top: y + "px", 
        left:x + "px" 
       } 
      ); 


      $(document).append(menuDiv); 


     }); 


function createMenuDiv() { 

    var menuDiv = document.createElement("div"); 
    $(menuDiv).css("background-color", "yellow"); 
    $(menuDiv).css("z-index", "99"); 


    var b = document.createElement("input"); 

    $(menuDiv).append(b); 

// var addButtonLabel = document.createElement("label"); 
// $(addButtonLabel).text("Add"); 
// 
// var deleteButtonLabel = document.createElement("label"); 
// $(deleteButtonLabel).text("Delete"); 

// $(menuDiv).append(addButtonLabel); 
// $(menuDiv).append(deleteButtonLabel); 

    return menuDiv; 

} 
+0

メニューは文書に正しく追加されていますか?はいの場合、それは単なるCSSの問題かもしれませんし、あなたの文書がどのようになっているかにもよるでしょう。 –

答えて

関連する問題