Jquery hover popup a div
Im using this Jquery to popup a div
<script type="text/javascript">
$(function () {
$('.bubbleInfo2').each(function () {
var distance = 10;
var time = 250;
var hideDelay = 500;
var hideDelayTimer = null;
var beingShown = false;
var shown = false;
var trigger = $('.trigger2', this);
var info = $('.popup2', this).css('opacity', 0);
$([trigger.get(0), info.get(0)]).mouseover(function () {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
if (beingShown || shown) {
// don't trigger the animation again
return;
} else {
// reset position of info box
beingShown = true;
info.css({
top: 40,
left: -160,
display: 'block'
}).animate({
top: '-=' + distance + 'px',
opacity: 1
}, time, 'swing', function () {
beingShown = false;
shown = true;
});
}
return false;
}).mouseout(function () {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
hideDelayTimer = setTimeout(function () {
hideDelayTimer = null;
info.animate({
top: '-=' + distance + 'px',
opacity: 0
}, time, 'swing', function () {
shown = false;
info.css('display', 'none');
});
}, hideDelay);
return false;
});
});
});
//-->
</script>
it's working well but i need to change in a way to be able to call it in a function and to pass the parameters beca开发者_如何学Cuse im using it several time on the page.In way to don;t have it many times on the page
that i would call it in something similar to this :
<script type="text/javascript">
jQuery(function ($) {
$(".bubbleInfo2").BubleFunction(....parameters to be passed
});
</script>
if you want that, you need to make jquery plugin, but it is simple check out http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
<script type="text/javascript">
function callthisfunction() {
$(".bubbleInfo2").BubleFunction(....parameters to be passed
}
精彩评论