jquery - 我的 JQuery show() 在 IE 中有效但在 FF 中无效?

标签 jquery css internet-explorer firefox

在我的 .Net 网络应用程序中,我有一些动态放置在页面上的元素类为“skmTooltipHost”。

当鼠标悬停在它们上面时,应该会显示一个工具提示类型的弹出窗口。这在 IE 中工作得很好,但在 Firefox 中完全没有。

请帮忙!

执行“悬停和显示”的 javascript

$(document).ready(function () {
  $(".skmTooltipHost").hover(function () {
      $(this).empty().append('<div class="skmTooltipContainer"><strong>hello</strong>' + $(this).attr('tooltip') + '</div>');
      $(this).find('.skmTooltipContainer').css("left", $(this).position().left + 20);
      $(this).find('.skmTooltipContainer').css("top", $(this).position().top + $(this).height());
      $(".skmTooltipContainer").css("display", "inline-block");
      $(".skmTooltipContainer").show();
      $(this).show();
   },function () {    
     $(".skmTooltipContainer").fadeTo(500, 1.0, function () { $(this).remove(); });
   });
});

我的 CSS

.skmTooltipHost
{
cursor: help;
border-bottom: dotted 1px brown;

}

.skmTooltipContainer
{
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 3px;
 display:inline-block;
position: absolute!important;
background-color: #ff9;
border: solid 1px #333;
z-index: 999;
}

编辑

我终于使用了一组不同但相似的代码,它们确实有效。我不确定有什么区别。我的工作代码如下:

 function simple_tooltip(target_items, name) {
      $(target_items).each(function (i) {
          $("body").append("<div class='" + name + "' id='" + name + i + "'><p>Click for a link to the run details</br><strong>Server:   </strong>" + $(this).attr('title') + "</br><strong>Information:</strong>" + $(this).attr('error') + "</p></div>");
          var my_tooltip = $("#" + name + i);

          $(this).removeAttr("title").mouseover(function () {
              my_tooltip.css({ opacity: 0.8, display: "none" }).fadeIn(100);
          }).mousemove(function (kmouse) {
              my_tooltip.css({ left: kmouse.pageX + 15, top: kmouse.pageY + 15 });
          }).mouseout(function () {
              my_tooltip.fadeOut(100);
          });
      });
  }
  $(document).ready(function () {
      simple_tooltip($(".skmTooltipHost"), "tooltip");
  });



.tooltip{
position:absolute;
z-index:999;
left:-9999px;
background-color:#dedede;
padding:2px;
border:1px solid #fff;
width:250px;

.tooltip p{
    margin:0;
    padding:0;
    color:black;
    background-color:white;
    padding:2px 7px;
}

最佳答案

this (jsfiddle)你正在使用的 CSS/HTML/JS?这在 Chrome 和 Firefox 中对我有用。这条线可能不会做你想要的:

$(".skmTooltipContainer").fadeTo(500, 1.0, function () { $(this).remove(); });

关于jquery - 我的 JQuery show() 在 IE 中有效但在 FF 中无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15358063/

相关文章:

css - 如何在 Twitter Bootstrap 中制作一个简单的内部容器?

javascript - 显示 :none not being recognized 的 CSS 问题

html - IE、Chrome 和 FireFox 的保存密码行为说明

java - 使用 Selenium Grid 从 linux hub 运行 IE 测试

jquery - 实时测试 jQuery 选择器

javascript - 如何在 Laravel 5.6 中使用 JQuery

返回文件结果后,jQuery 重新启用表单

javascript - 如何添加相当于 .mouseLeave 的触摸

jquery - Applet 阻止 IE 中的焦点

jquery - 通过 JSON 文件在动态创建的表上运行 dataTable