Load Javascript function when opening page

1

I do not understand much of the subject, though, I'll try to explain. Currently when I pass the mouse over a div with the class tooltips , the following script is executed:

$('.tooltips').tooltip();

However, I would like this to happen soon after loading the page, so you do not have to pass the mouse on the div or click on it.

How can I do this?

    
asked by anonymous 30.10.2015 / 19:34

2 answers

1

You can do this as follows:

$(document).ready(function() {
    $("#link").tooltip({ show: {duration: 800} });
    $("#link").trigger('mouseenter');
});

$('html').click(function() {
    $("#link").trigger('mouseleave');
});

What this will do is show tooltip using the .show when the document is ready, simulating the action of mouseenter/mouse hover on the link and then when clicked anywhere in the document, remove that action with mouseleave .

Here's an example online at jsFiddle: link

    
30.10.2015 / 21:12
0

Since you're using JQuery and not pure Javascript, try $(document).ready(suaFunção)

    
30.10.2015 / 19:38