2012-11-30 141 views
2

是否有任何标准方法为buttonset中的每个单选按钮添加工具提示?JQuery UI ButtonSet工具提示

<span id="tools"> 
    <input type="radio" id="feature1" name="tool" title="feature 1"><label for="feature1">Tool 1</label> 
    <input type="radio" id="feature2" name="tool" title="feature 2"><label for="feature2">Tool 2</label> 
</span> 

和脚本:

$('#tools').buttonset(); 

我已经添加标题为每个输入,但没有任何提示。

回答

5

你可以使用类似这样

$(function() { 
    ​$('label').each(function() { 
     var radio = $(this).prop('for')​​​​​​​​; 
     $(this).prop('title',$('#' + radio).prop('title')); 
    }); 
}); 

所有它依赖于为jQuery和for属性每个标签是正确的。

+0

谢谢!这就是我一直在寻找的! – Coffka

0

您可以简单地将标题属性移动到标签。

+0

并围绕单选按钮包装标签 –