我正在尝试使用允许我定义自定义工具提示的小型 jQuery 脚本替换我应用中所有元素的默认工具提示 (title="*")。
<div>
<input type="text" title="default tooltip" />
<textarea type="text" title="default tooltip"></textarea>
<select title="default tooltip"><option>select</option></select>
</div>
.
$(function() {
$('input, textarea, select, p, label').tooltip({
hide: {
effect: "explode",
delay: 250
}
});
});
检查 fiddle :http://jsfiddle.net/tnEmZ/1/
最佳答案
var $title = $("a,input,p,label,textarea[title]"); //get all elements with the title-Attribute
//loop through title-elements
$.each($title, function(index, value) {
$(this).tooltip({
show: {
effect: "explode",
delay: 250
},
hide: {
effect: "explode",
delay: 250
}
});
});
演示 here
关于javascript - 用 jQuery 工具提示替换所有标题默认工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14702359/