views:

3803

answers:

4

Is there a way to disable browser tooltip from displaying when hovering over elements that have attribute 'title' populated? Note that I don't want to remove title content. Here is the code are requested:

  $(document).ready(function() {
     $('a.clickableSticky').cluetip({
         splitTitle: '|',
         showTitle: false,
         titleAttribute: 'description',
         activation: 'click',
         sticky: true,
         arrows: true,
         closePosition: 'title'
     });
 });

and in asp.net

  <ItemTemplate>
     <a class="clickableSticky" href="#"
     title=' <%#((Limit)Container.DataItem).Tip %>'>
     <img src="..\App_Themes\default\images\icons\information.png"/>
     </a>

 </ItemTemplate>
+3  A: 

You could use jQuery to remove the contents of the title attribte, or move it into some other parameter for later use.

This does mean you lose some accessibility though.

RE: ClueTip A search of Google seems to suggest this is a common problem - is this only happening in IE? ClueTip seems to work as expected in FireFox.

Mike Houston
I don't want to remove title attribute. I am using 'Cluetip' plugin, and I need the title attribute. Problem is that that ugly yellow tooltipe appears for a second, before cluetip shows up.
epitka
@epitka - You could have mentioned that in question.
karim79
I am sorry, after I posted it I noticed it and revised it
epitka
+13  A: 

You could remove the title attribute on page load.

$(document).ready(function() {
    $('[title]').removeAttr('title');
});

If you need to use the title later, you can store it in the element's jQuery data().

$(document).ready(function() {
    $('[title]').each(function() {
        $this = $(this);
        $.data(this, 'title', $this.attr('title'));
        $this.removeAttr('title');
    });
});

Another option is to change the name of the title attribute to aTitle, or something else that the browser would ignore, and then update any JavaScript to read the new attribute name instead of title.

Update:

An interesting idea you could use is to "lazily" remove the title when hovering over an element. When the user hovers off the element, you can then put the title value back.

This isn't as straightforward as it should be because IE doesn't handle setting the title attribute to null or removing the attribute on hover. The trick is to set the tooltip to an empty string ("") on hover. This will effectively remove the tooltip from all browsers.

You can use the method I mentioned above to store the title attribute in jQuery's data(...) method and then put it back on mouseout.

Dan Herbert
Cool snippet, didn't really think through how I would've done it but I like the easiness of this approach
Andrew G. Johnson
+1 for code example :)
Mike Houston
That is what I am currently doing, storing in description field, but I thought I could have it in title and ignore it
epitka
If you're wanting to keep the titles there, this won't work. Likely, this will break screen-readers for the visually-impaired.
Jonathan Sampson
As if screen-readers are going to interpret Javascript anyways...? C'mon people!
Josh Stodola
Screen readers are quite capable of dealing with JavaScript. However, it is safe to assume they will never trigger the `hover` event so mangling the title on hover would be legitimate.
cweider
+1  A: 

Hack up ClueTip to use a renamed title attribute.

Detect
A: 

thanks buddy it helped me well ...

hayri