0

I have the following on a plugin:

$(this).mouseenter(function (e) {
  var this = $(this);
  var text = "<div class="Text">" + options.Text + "</div>"
  $("body").append(text);
})

How to align "text" to "this" before adding it to body on the following positions: TopCenter, BottomCenter, RightMiddle or LeftMiddle.

Thank You!

4

2 回答 2

0
$(this).on('mouseenter', function() {
    var $this = $(this),
        text  = $('<div />', {'class': 'text',
                              text   : options.Text,
                              style  : 'position   : relative;  
                                        margin     : 0 auto; 
                                        text-align : center;'
                             }
                 );
    $("body").append(text);
}):
于 2013-04-08T22:11:31.467 回答
0
  1. 您不应该使用“this”作为本地参数,因为那是一个保留的 javascript 字。
  2. 您可以在 div 中添加样式以对齐文本。

    var $this = $(this); 
    $this.mouseenter(function (e) {
       var text = "<div class='Text' style='text-align:left'>" + options.Text + "</div>"
       $("body").append(text);
    });
    
于 2013-04-08T23:22:26.830 回答