simberak Posted August 18, 2017 Share Posted August 18, 2017 Hello, is there a way how to force stop displaying img alt on hover? Some way instead of deleting alt from code? Thank you very much, Daniel Link to comment Share on other sites More sharing options...
BonPresta Posted August 18, 2017 Share Posted August 18, 2017 Hello, is there a way how to force stop displaying img alt on hover? Some way instead of deleting alt from code? Thank you very much, Daniel In the file global.js at the very end, add this code $(document).ready(function(){ (function($){ $.fn.hideTips = function(){ return this.each(function(){ var $elem = $(this) var savealt = $elem.attr('alt'); var savetitle = $elem.attr('title'); $elem.hover(function(){ $elem.removeAttr('title').removeAttr('alt'); },function(){ $elem.attr({ title:savetitle, alt:savealt}); }); }); }; })(jQuery); $(function(){ $('a').hideTips(); $('img').hideTips(); }); }); Link to comment Share on other sites More sharing options...
simberak Posted August 21, 2017 Author Share Posted August 21, 2017 Thank you! And could you tell me, where this global.js is located? Link to comment Share on other sites More sharing options...
BonPresta Posted August 21, 2017 Share Posted August 21, 2017 Thank you! And could you tell me, where this global.js is located? In the theme there is a folder js? He should be there 1 Link to comment Share on other sites More sharing options...
simberak Posted August 22, 2017 Author Share Posted August 22, 2017 Oooo yeees, I was finding it in root Thank you Link to comment Share on other sites More sharing options...
simberak Posted August 22, 2017 Author Share Posted August 22, 2017 And one more question. If I want it only for imgs (not for links) I will just delete the code: $('a').hideTips(); Is that right? Link to comment Share on other sites More sharing options...
prestahero.com Posted August 23, 2017 Share Posted August 23, 2017 Hello, is there a way how to force stop displaying img alt on hover? Some way instead of deleting alt from code? Thank you very much, Daniel Actually when you hover over an imag, which is displayed is not img alt it's img title. To force remove the title of img you can add this javascript code your js file: $(document).ready(function(){ $('img').attr('title',''); }); if you also want to remove alt then $(document).ready(function(){ $('img').attr('alt',''); }); Link to comment Share on other sites More sharing options...
BonPresta Posted August 23, 2017 Share Posted August 23, 2017 Actually when you hover over an imag, which is displayed is not img alt it's img title. To force remove the title of img you can add this javascript code your js file: $(document).ready(function(){ $('img').attr('title',''); }); if you also want to remove alt then $(document).ready(function(){ $('img').attr('alt',''); }); Forced is not necessary, it's bad for SEO When hovering it was necessary... 1 Link to comment Share on other sites More sharing options...
prestahero.com Posted August 23, 2017 Share Posted August 23, 2017 Forced is not necessary, it's bad for SEO When hovering it was necessary... I don't think it would affect SEO because this javascript it only happens when you browse the site on an web browser with javascript support. The alt and title tags are still in website source code (which search engine read) Link to comment Share on other sites More sharing options...
simberak Posted August 23, 2017 Author Share Posted August 23, 2017 And the code from you BonPresta is only for hover right? Link to comment Share on other sites More sharing options...
BonPresta Posted August 23, 2017 Share Posted August 23, 2017 And the code from you BonPresta is only for hover right? Yes, it is only for hover Link to comment Share on other sites More sharing options...
simberak Posted August 23, 2017 Author Share Posted August 23, 2017 Great, thank you once more Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now