Here I will be having title for an image and I need this title for other purpose. But I don't want that title to be displayed on hover of the image. Sooner reply will be appreciated. Thanks in advance.
Asked
Active
Viewed 974 times
0
-
If you want to use the title for other purpose , why not use user defined attribute in your tag? e.g. user-title=" " , etc. and get that attribute as $('anyid').attr('user-title'); – Newinjava Jun 03 '15 at 12:43
-
Maybe you should switch from title to alt-attribute? Not sure why you are needing a title. – Sabrina Jun 03 '15 at 12:50
2 Answers
3
Don't apply it using the title attribute, but with a data attribute. That way the default behavior won't be invoked, but you will still be able to access it for your purposes.
<img data-title="Image Title" ...

tvanfosson
- 524,688
- 99
- 697
- 795
0
If you can, move the title to data-title, that's a custom attribute that you can use for other purposes for your title.
If you can't, you could use a js like this
$("img").mouseenter(function(){
// Get the current title
var imgtitle = $(this).attr("title");
// Store it in a temporary attribute
$(this).attr("data-title", imgtitle);
// Set the title to nothing so we don't see the tooltips
$(this).attr("title","");
});
$(".element").mouseleave(function(){
// get the attribute back
var imgTitle = $(this).attr("data-title");
// Set the title back
$(this).attr("title","imgtitle ");
});
That ought to do the trick

Vlad Pintea
- 813
- 8
- 24