سؤال

لدي المشكلة التالية. أنا أعمل على Tooltip مسج بسيط والآن أتعامل مع شيء غريب بالنسبة لي. في كل مرة أستخدم فيها العنصر، يتم تشغيل الأحداث الخاصة بالماوس والماوس خارج كليهما - لذلك يختفي Tooltip (ولكن إذا استمرت في تسليمها، فهذا يفعل ذلك كثير من يومض في ثانية واحدة). هناك الكود الخاص بي.

  var hint = $('<div id="hint-wrap"><div id="hintbox-top"><div id="hintbox-bottom"><div id="hintbox-topleft"><div id="hintbox-bottomleft"><div id="hint-innerwrap"><div id="hint"></div></div></div></div></div></div></div>'); // Funny I know :-D

  hint.hide();
  $('body').append( hint ); // I append it

  $('.hashint').hover(function(e){   

// Set position to cursor's
hint.css( 'left', e.pageX );
hint.css( 'top', e.pageY - 60 );

// animated append
hint.css( 'opacity', 0.2 );
hint.show();
hint.animate( { 'opacity' : 1 }, 100 );

// set text
$( "#hint" , hint).html( $( '#' + $(this).attr( 'id' ) + '-hint' ).html() ); 

 },
 function(){ // there is the problem
    hint.hide();
  });

و HTML:

<div id="usernamelabel-hint" class="hinttext">Lorem Ipsum is simply dummy text of the printing and type.Lorem. <a href="#">Sign up!</a></div> <!-- This is hint text (and code) -->
<p><label><span class="hashint" id="usernamelabel">Username</span><span class="asterisk">*</span></label> <!-- ... stuff --> </p>

من فضلك، هل يعرف أي شخص لماذا الحدث الفأر لا يزال يسبب واختبئ صندوقي؟

شكرا جزيلا، ondrej

هل كانت مفيدة؟

المحلول

هل يمكن أن يكون ذلك، أن Tooltip-div هو تراكب الزناد الخاص بك؟ في هذه الحالة، يظهر ToolTip-DIV DIV المهرج من الزناد - Div .. على الأقل هذا ما يحدث لي بعض divs. لقد حلت هذه المشكلة من خلال تراكب كل شيء مع الزناد غير مرئي - ليست جميلة جدا، لكنها عملت بالنسبة لي ..

نصائح أخرى

أولا، لماذا لا تضع HTML فقط للتلميح في مستند HTML؟
وفي CSS أنت فقط تعيين العرض: لا شيء؟
ثم عند إظهار التلميح، يمكنك فقط استخدام hint.show أو hint.fadeIn.

أود فقط استخدام $. mouseenter. و $ .mouseleave..

مثال:

$.('#usernamelabel-hint').mouseenter(function() { 
  // show or fade inn hint text
});

$.('#usernamelabel-hint').mouseleave(function() {
  // Hide or fade out hinttext
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top