我正在使用coda风格的jquery插件来显示气球工具提示。这里是链接:http://www.uhleeka.com/blog/2009/11/bubbletip/如何编写通用jquery函数来显示工具提示
我写了这个jquery显示气球工具提示单击元素。
这是我在做这个ID的,但我怎么能做到这一点使用类名。 我怎么能insted每个id的写作bubbletip函数我怎么能写单(常用)jquery函数来应用bubbletip。
<script type="text/javascript">
$(document).ready(function() {
$('#fee').bubbletip($('#tip1_focusblur'), {
deltaDirection: 'right',
bindShow: 'click',
bindHide: 'blur'
});
$('#price').bubbletip($('#tip2_focusblur'), {
deltaDirection: 'right',
bindShow: 'click',
bindHide: 'blur'
});
});
</script>
<p>Input box 1<input type="text" id="fee" value="focus me!" /></p>
<div id="tip1_focusblur" style="display:none; max-width:330px;">
<pre class="tip">
This is the div where help can be display.
</pre>
</div>
<p>Input box 2<input type="text" id="price" value="focus me!" /></p>
<div id="tip2_focusblur" style="display:none; max-width:330px;">
<pre class="tip">
This is the div where help can be display.
</pre>
</div>
编辑: 我发现soloution:每 作为JofryHS建议,我已经尝试这种解决方案。
这是一个很好的解决方案吗?
的Javascript:
$(document).ready(function() {
var count = 0;
$('[data-bubble]').each(function() {
count++;
var data = $(this).attr('data-bubble');
$(this).parent().append($('<div class="bubble" id="bubble_'+ count+ '">' + data + '</div>'));
$(this).bubbletip('#bubble_'+count, {
deltaDirection: 'right',
bindShow: 'click',
bindHide: 'blur'
});
});
});
HTML:
<input type="text" data-bubble="This is Test text 1" value="focus me!" />
<input type="text" data-bubble="This is Test text 2" value="focus me!" />
我已经找到了解决方案。看我的编辑 – Kango