Positioning the tooltip to the right or left of the cursor


show more Positioning the tooltip to the right or left of the cursor provides you with in-depth training on Developer. Taught by Chris Converse as part of the Create a Tooltip with jQuery show less
please wait ...

Positioning the tooltip to the right or left of the cursor

So the first detection we're going to do is for the pageWidth, so that we know whether we need to align the tooltip to the right or left, depending on where the mouse cursor is. So after the variables for tooltip width and height, let's come in here and declare another variable, var, space, pageWidth. We're going to set that equal to = $(), tick marks for string literal 'body', outside of the parentheses .width(); so the width of the overall browser is now going to be stored in this pageWidth variable.

Next line, let's type a JavaScript conditional statement, if, beginning and ending parentheses, beginning and ending bracket, open up the brackets. Inside of the parentheses we want to detect the position x of the cursor so e.pageX > pageWidth/2. So if pageX is greater than pageWidth/2, we know that the cursor is on the right-hand side of the screen.

So what we want to do inside of here is type $() tick marks for string literal, pound sign ('#tooltip_container&...

Positioning the tooltip to the right or left of the cursor
Video duration: 3m 29s 54m 23s Intermediate

Viewers:

Positioning the tooltip to the right or left of the cursor provides you with in-depth training on Developer. Taught by Chris Converse as part of the Create a Tooltip with jQuery

Subjects:
Developer Web
Software:
jQuery
Author:
please wait ...