I am using coda style jquery plugin to show balloon tooltip. Here is link :http://www.uhleeka.com/blog/2009/11/bubbletip/
I have written this jquery to display ballon tooltip on click of element.
This what i am doing this on id's but how can i do this using class name. How can i do insted of writting bubbletip function for each id's how can i write single(common) jquery function to apply 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>
Edit: I have found soloution: As per JofryHS suggest , i have tried this solution.
Is this good solution ??
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!" />