简体   繁体   中英

How to know when the cursor has halted somewhere?

I have a graph, and I want to display the value onder the cursor by using the default tooltip (set by the Title attribute). To show the right value in the tooltip, I could calculate the value each time the mouse moves over the graph, so that if the mouse pauses it shows the right tooltip. But this calculation requires a lot of performance, so I'd rather wait with updating the text in the Title attribute, until the cursor is halted, so that I don't do unnecessary calculations for a tooltip that is invisible.

Is there an event for this?

Check this, i think it will helps you

<title id="title_id">example</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
 function set_title(val) {
     $("#title_id").html(val);
 }
</script>
<input type="text" name="time" value="" onchange="set_title(this.value);">

when you change the value in the input field, the title will change

What you need to do is to build a custom event that is fired after the mouse has become stationary within an element. Something like a mousestop event.

Fortunately, this plugin seems to provide this functionality for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM