| jqyery tooltip
widget |
to display if we hover on input element, it
wil display the title |
|
|
|
|
| In
this video we will discuss jQuery tooltip widget with examples. |
|
|
| To
get a tooltip without using jQuery all you do is set the title attribute. At
this point when we hover over the element the content that is specified as
the value for the title attribute will be displayed as the tooltip. |
|
|
| jQuery
Tooltip widget replaces native tooltip and allows lot of customization |
| 1.
Display other content than just the title, like inline footnotes or extra
content retrieved via Ajax. |
| 2.
Customize the positioning, e.g., to center the tooltip above elements. |
| 3.
Add extra styling to customize the appearance, for warning or error fields. |
|
|
| In
the following example label element display the native tooltip where as the
textbox displays jQuery tooltip |
|
|
| HTML |
|
| <label
id="lblName" for="txtName" title="Full
Name">Name</label> |
| <input
id="txtName" type="text" title="Your full name as it
appears in paasport" /> |
|
|
| jQuery |
|
| $('#txtName').tooltip(); |
|
|
|
| In
the following example we are calling tooltip() function on the document
object, so this will display jQuery tooltip for all the elements that have
title attribute |
| $(document).tooltip(); |
isntead of using on every element, it is best to use at document |
|
|
| You
can also use the content option, to specify the content for tooltip. When
both title attribute and content options are specified, the content specified
by the content option will override the content specified by the title
attribute. |
|
|
| HTML |
|
| <input
id="txtName" type="text" title="Your full name as it
appears in paasport" /> |
|
|
| jQuery |
|
| $('#txtName').tooltip({ |
if we want to overwrite the title of specific element use this |
| content : '<u>content
option</u> tooltip overriding title attribute tooltip' |
| }); |
|
|
|
| content
option supports multiple types. string or a function. |
|
|
| HTML |
|
| <input
id="txtName" type="text" title="Your full name as it
appears in paasport" /> |
|
|
| jQuery |
|
| $(document).ready(function ()
{ |
|
| $('#txtName').tooltip({ |
function inside a function |
| content: toolTipFunction |
|
| }); |
|
|
|
| function toolTipFunction() { |
|
| return 'Tooltip from a function'; |
|
| } |
|
| }); |
|
|
|
| Set
track option to true to make the tooltip follow the mouse |
|
|
| HTML |
|
| <input
id="txtName" type="text" title="Your full name as it
appears in paasport" /> |
|
|
| jQuery |
|
| $('#txtName').tooltip({ |
|
| track: true |
it follows mouse, whereever mouse follows or hovers, at that it displays
title |
| }); |
|
|
|
| show
and hide options can be used to animate the showing and hiding of the
tooltip. Both of these options support multiple types. For the detailed
description please check the following jquery documentation page |
| http://api.jqueryui.com/tooltip |
|
|
|
| In
the following example we are using a JavaScript object, to specify the
animation duration, effect and delay while the tooltip is being shown and
hidden |
|
|
| HTML |
|
| <input
id="txtName" type="text" title="Your full name as it
appears in paasport" /> |
|
|
| jQuery |
|
| $('#txtName').tooltip({ |
show after some seconds and upto some time with effct |
| show : {delay:10, duration:500, effect:
'slideDown'}, |
animate |
| hide: { delay: 10, duration: 500, effect:
'slideUp' } |
|
| }); |
|
|
explode effect break the glass effect |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| display the title
next to iamge or ekleent |
| how to over ride all title using tooltop |
| write the title into textname id |
| how to write the title value where mouse
is shown |
| how to show tooltip with delay |
|
|
|
|
|
|
|
No comments:
Post a Comment