简体   繁体   English

如何在我所有的单选按钮上悬停jquery工具提示

[英]How to have jquery tooltip hover on all my radio buttons

I have a form in which I have a button at the top. 我有一个表单,上面有一个按钮。 If I click that button, then it shows four radio buttons at the bottom.. And now I am planning to have jquery tool tip hover on all my Radio Buttons. 如果单击该按钮,那么它将在底部显示四个单选按钮。现在,我计划将jQuery工具提示悬停在所有单选按钮上。

Here is my jsfiddle . 这是我的jsfiddle

  • If I am moving my mouse on TEST1 radio button, I would like to show Hello Test1 如果要在TEST1单选按钮上移动鼠标,我想显示Hello Test1
  • If I am moving my mouse on TEST2 radio button, I would like to show Hello Test2 如果要在TEST2单选按钮上移动鼠标,我想显示Hello Test2
  • If I am moving my mouse on TEST3 radio button, I would like to show Hello Test3 如果要在TEST3单选按钮上移动鼠标,我想显示Hello Test3
  • If I am moving my mouse on TEST4 radio button, I would like to show Hello Test4 如果要在TEST4单选按钮上移动鼠标,我想显示Hello Test4

Is this possible to do? 这可能吗? I saw this example but they have radio button in div somehow so not sure how would this work in my situation. 我看到了这个示例,但是它们以某种方式在div中具有单选按钮,因此不确定在我的情况下该如何工作。

Can anyone provide jsfiddle example? 谁能提供jsfiddle示例?

NOTE:- 注意:-

Hello Test1 is just an example, it can be any word or paragraph of two three lines.. When I will be integrating the code, I will use different words for all my radio buttons.. Hello Test1只是一个示例,它可以是两个三行中的任何单词或段落。当我集成代码时,我将为所有单选按钮使用不同的单词。

here is attach demo link please see it : 这是附加的演示链接,请查看:

http://jsfiddle.net/4Nmqk/32/ http://jsfiddle.net/4Nmqk/32/

add this to your js 将此添加到您的js

$('label').tooltip({
    placement : 'top'
});

you html is like this 你的HTML是这样的

    <label  title='hello test1'><input type="radio" name="data" id="data" value="test1">TEST1 </label>
    <label title='hello test2'><input type="radio" name="data" id="data" value="test2">TEST2 </label>
    <label  title='hello test3'><input type="radio" name="data" id="data" value="test3">TEST3 </label>
    <label  title='hello test4'><input type="radio" name="data" id="data" value="test4">TEST4 </label>

you want any other name to each input you can change title of label tag as your choice. 您希望每个输入都有其他名称,您可以选择更改标签的标题。

you also use id=data for all four input this is not valid html you can use id's same value only one time for page so give different id value for all four input or you can use class instead of id. 您还对所有四个输入都使用id = data这是无效的html,您只能在页面上一次使用id的相同值,因此为所有四个输入提供不同的id值,或者可以使用类代替id。

You can iterate the radio buttons and set title for it 您可以迭代单选按钮并为其设置标题

$("input[type*=radio]").each(function(i,value){ 
    $(this).attr("title","Hello "+$(this).val());
    });

http://jsfiddle.net/4Nmqk/30/ http://jsfiddle.net/4Nmqk/30/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM