jQuery event "looping"

I´m trying to code a tooltip (Yes I know, I have my reasons to avoid plugins in this case) in jQuery. Whe I show the tooltip and leave the mouse in the same place the show and hide repeats forever. It´s like the element triggers the hover event again and again and again. I try unbind for the event but it does not work neither. $("td.with-tooltip").mouseover( function() { var offset = $(this).offset(); var baseX = offset.left; var baseY = offset.top; var inputWidth = $(this).width(); var baseX = baseX + 50; var baseY = baseY - $(".desc").height(); $(".desc div").html($(this).attr("title")); $(".desc").css({"position":"absolute", "left": baseX, "top": baseY }).fadeIn(); $(this).unbind("mouseover"); }).mouseleave( function() { $(".desc").fadeOut(); }); What can I do? thanks. I solved with this code, thanks for everybody, really.
	var t;
	var xOffset;
	var yOffset;


		t = $(this).attr("title");
		$(this).attr("title", "");

		$(".desc div").text(t);

		xOffset = $(".desc").height() + 30;
		yOffset = -20;
					.css("botton",(e.pageY + xOffset) + "px")
					.css("left",(e.pageX + yOffset) + "px").fadeIn("fast");
		$(this).attr("title", t);
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");

You should accept answers to your questions by clicking the checkmark beside the answer that helped you most...it makes your questions much more appealing to answer. Not doing it is a red-flag for many would-be answerers that there's no chance of reward for answering.

以上就是jQuery event "looping"的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准