Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:02:11+00:00 2026-05-25T02:02:11+00:00

I -with some stackoverflow users help- have developed this tooltip script using Jquery and

  • 0

I -with some stackoverflow users help- have developed this tooltip script using Jquery and general Javascript,

    <script type="text/javascript">

$(document).ready(function(){
        /*OPCIONES DEL PLUGIN*/
        var selector = '.disparador'; //elemento que activará el tooltip
        var tooltip = '.miTooltip';   //elemento con el contenido HTML a mostrar por el tooltip
        var tiempo_espera = 0;        //tiempo que el tooltip esperará a desaparecer una vez el raton se salga del disparador
        var seguir_raton = true;      //booleana que determina si el tooltip debe seguir el movimiento del raton o no
        var ajuste_top = 0;           //distancia vertical de ajuste
        var ajuste_left = 0;          //distancia vertical de ajuste
        var fade_time = 300;          //tiempo de la transición de mostrar/ocultar
        /*ARCHIVOS NECESARIOS DEL PLUGIN - NO TOCAR*/




        /* Detectar que el raton pasa por encima */
        $(selector).hover(function(e) {
          /*Guardamos el selector del disparador y de tooltip en una variable*/
            var disp = $(this);
             var tip= disp.next(tooltip);
             var tip_text = tip.html();
             //alert(tip_text);
             var new_content = '<span class="left"></span ><span class="contenido">'+tip_text+'</span ><span class="right"></span ><span class="bottom"></span >';
             //alert(new_content);
             tip.html(new_content);
            if(typeof t != 'undefined'){
                /*reiniciamos tiempo_espera*/
                clearTimeout(t);
            }
                $(tip).css({
                    /*colocamos el tooltip según el ratón y el tamaño del tooltip*/
                    left: e.clientX-($(tip).width()/2)+ajuste_left+'px',
                    top: e.clientY-$(tip).height()*3/2+ajuste_top+'px'
                }).fadeIn(fade_time);

        });
        /* En caso de que se mueva el raton */
        $(selector).bind('mousemove', function(e){
            if(seguir_raton==true){
                var disp = $(this);
                var tip= $(this).next(tooltip);
               $(tip).css({
                   /*Pues recolocamos el tooltip*/
                    left: e.clientX-($(tip).width()/2)+ajuste_left+'px',
                    top: e.clientY-$(tip).height()*3/2+ajuste_top+'px'
                });
            }
        });

        $(selector).mouseout(function() {
            /*añadimos tiempo_espera por si el usuario se sale sin querer*/
            t = setTimeout("$('"+tooltip+"').fadeOut("+fade_time+")",tiempo_espera);
        });
});



</script>

It has some variables at the beggining and they are all optional as they have all initial values, but i’d like to be able to be variables for the init,

According to this: tutorial i need to do something like:

    (function($){

    $.fn.meliaTooltip = function(options){


    // code will be added here.

    }
})(jQuery);

But I’m not sure if i have to pase the code in there and how exactly define the options (asuming options are the parametres to be used as my variables)

Anyone feels like giving me a push?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:02:12+00:00Added an answer on May 25, 2026 at 2:02 am

    It should look like this:

    (function ($) {
        $.fn.meliaTooltip = function (options) {
            var defaults = {
                tooltip: '.miTooltip',
                tiempo_espera: 0,
                seguir_raton: true,
                ajuste_top: 0,
                ajuste_left: 0,
                fade_time: 300
            };
    
            var opts = $.extend(defaults, options);
    
            $(this).each(function() {
                $(this).hover(function(e) {
                    /*Guardamos el selector del disparador y de tooltip en una variable*/
                    var disp = $(this);
                    var tip = disp.next(opts.tooltip);
                    var tip_text = tip.html();
                    //alert(tip_text);
                    var new_content = '<span class="left"></span ><span class="contenido">' + tip_text + '</span ><span class="right"></span ><span class="bottom"></span >';
                    //alert(new_content);
                    tip.html(new_content);
                    if (typeof t != 'undefined') {
                        /*reiniciamos tiempo_espera*/
                        clearTimeout(t);
                    }
                    $(tip).css({
                            /*colocamos el tooltip según el ratón y el tamaño del tooltip*/
                            left: e.clientX - ($(tip).width() / 2) + opts.ajuste_left + 'px',
                            top: e.clientY - $(tip).height() * 3 / 2 + opts.ajuste_top + 'px'
                        }).fadeIn(opts.fade_time);
    
                });
    
                $(this).bind('mousemove', function(e) {
                    if (opts.seguir_raton) {
                        var disp = $(this);
                        var tip = $(this).next(opts.tooltip);
                        $(tip).css({
                                /*Pues recolocamos el tooltip*/
                                left: e.clientX - ($(tip).width() / 2) + opts.ajuste_left + 'px',
                                top: e.clientY - $(tip).height() * 3 / 2 + opts.ajuste_top + 'px'
                            });
                    }
                });
    
                $(this).mouseout(function() {
                    /*añadimos tiempo_espera por si el usuario se sale sin querer*/
                    t = setTimeout("$('" + opts.tooltip + "').fadeOut(" + opts.fade_time + ")", opts.tiempo_espera);
                });
            });
        };
    })(jQuery);
    

    usage:

    $("#selector").meliaTooltip({
        tooltip: '.miTooltip',
        fade_time: 300
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed web applications using JSF (myfaces components). But in these days of
I've completed my little app with some help here on StackOverflow so now I
Thanks to some very helpful stackOverflow users at Bit twiddling: which bit is set?
There have been some similar questions in stackoverflow but none of them answers my
I have a script that appends some rows to a table. One of the
Duplicate : https://stackoverflow.com/questions/135651/learning-unit-testing I'm trying to develop some software for my research group to
There has been some talk of Website performance monitoring tools and services on stackoverflow,
Having read an existing post on stackoverflow and done some reading around on the
I'm trying to implement the WMD editor used on StackOverflow to create some basic
Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.