简体   繁体   English

如何使用 jquery 将标题标签插入 img 标签

[英]how to insert title tag into the img tag using jquery

Below is my code to insert the title to all the img but it doesn't seem to work.下面是我将标题插入所有 img 的代码,但它似乎不起作用。

jQuery(document).ready(function() {


           $('img').attr('title','my title value');


      });

Jquery is properly working and shows all the insert and other operations but only this task i am stuck and don't know how to best accomplish it. Jquery 工作正常并显示所有插入和其他操作,但只有这个任务我被卡住了,不知道如何最好地完成它。

Are you certain its not working?你确定它不工作吗? Have you viewed the generated source to see the title attribute not there?您是否查看了生成的源以查看标题属性不存在?

If your just testing it by hovering your mouse over the image then it may not show if you have an alt tag specified.如果您只是通过将鼠标悬停在图像上来测试它,那么它可能不会显示您是否指定了 alt 标签。

Also what version of jQuery are you running?还有你在运行什么版本的 jQuery?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM