Title being displayed on hovering is the default function as the title is to just explain or describe the actual purpose of the element to the user. For example hover over to the following paragraph.
Hover over me.
You can write your own functions for handling the events in web pages. To handle the focus event you would write this code,
$('selector').focus(function () {
});
.. this would trigger each time focus is on the selected element. Let us work out for the title, for example, you wanted to show the title attribute property of the element upon focus on the screen, you would write this code,
$('selector').focus(function () {
$('p').text($(this).attr('title')));
});
You should first and foremost read the Solution 1 because Sergey has provided the reference links to the resource web pages you should read, I am going to add a little information to it. First thing is, you cannot trigger that "Show title" function of the browser anyway, not by focusing not by hovering over it. That is; I don't know how and why, the browser's behaviour. Secondly, you would use that
$('body').append('<span class="title">Hello World!</span>');
.. function to create a new element, and add the content to it and add a few styles to it to make it float over other elements. You would create a time interval to remove the element you just created, for example think of the setTimeout,
setInterval(removeTitle, 5000);
function removeTitle () {
$('span.title').remove();
}
One last thing I am going to add to the Solution 1 is that Sergey has said to write your own fiddles. Yup! That is true you should always write your own or just get an idea of code from other people don't copy/paste it. What I think, is the problem with this code, is that I don't think there is any t property in your context which would have that title attribute's value. That is the actual trouble in your code.
this.t = this.title;
this.title = "";
Tip: When working with jQuery code, always use the jQuery object (
$(this)
) and not the JavaScript object (
this
). It will also prove to be helpfull while working with objects.