首页 > forms > 当没有给出“title”属性时,工具提示javascript会破坏以下表单元素

当没有给出“title”属性时,工具提示javascript会破坏以下表单元素 (Tooltip javascript disrupts following form element when “title” attribute not given)

问题

我正在使用jqueryTOOLS提供的javascript工具提示来提供表单中的工具提示。

对于一些不需要工具提示的表单元素,我想将标题字符串留空,但是如果我这样做,那么它会导致表单的后续元素中断 - 几乎就像它将它们视为工具提示一样:on mouseover一个没有标题字符串的元素,它移动以下元素的位置,将其悬停在该字段旁边,然后当不再聚焦时,它会永久消失。

我的工具提示代码:

$(function() {
$("#myform :input").tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.7
  });
});

您可能已经猜到这个工具提示基于字段的'title'属性。

包括之后

<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>

在标题中。

希望我对事件的描述有意义!

在此先感谢您的帮助

解决方法

我想到了:

触发器元素被定义为所有输入,因此在缺少title元素时使用next作为工具提示。

只是jqueryTOOLS派对的一个错误,但一个简单的解决方案:

更换

$("#myform :input")

$("#myform :input[title]")

希望这有助于其他人

问题

I'm using a javascript tooltip provided by jqueryTOOLS to give tool tips within a form.

For some form elements that do not require a tool tip I want to leave the title string blank, however if I do this then it causes disruption in the subsequent elements of the form - almost as if it is treating them as a tool tip: on mouseover an element with no title string it moves the following element's position to hover next to the field, then when no longer focused it disappears permanently.

My tooltip code:

$(function() {
$("#myform :input").tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.7
  });
});

As you have probably guessed this tool tip is based on the 'title' attribute of a field.

After having included

<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>

in the header.

Hopefully my description of events made sense!

Thanks in advance for any help

解决方法

I figured it out:

The trigger element was defined to all inputs, so it was using the next as a tooltip in the lack of a title element.

Just a bug on the party of jqueryTOOLS but an easy solution:

replace

$("#myform :input")

with

$("#myform :input[title]")

Hope this helps someone else

相似信息