Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 将鼠标悬停在图像上时不显示alt文本_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 将鼠标悬停在图像上时不显示alt文本

Ruby on rails 3 将鼠标悬停在图像上时不显示alt文本,ruby-on-rails-3,Ruby On Rails 3,我有以下代码: <td><%= link_to(image_tag("delete.gif", :size => "16x16", :alt => "Delete Entry"), phone, :confirm => 'Are you sure?', :method => :delete, :remote=>true, :class=>'delete_phone') %></td> “16x16”、:alt=>“删除

我有以下代码:

<td><%= link_to(image_tag("delete.gif", :size => "16x16", :alt => "Delete Entry"), phone, :confirm => 'Are you sure?', :method => :delete, :remote=>true, :class=>'delete_phone') %></td>  
“16x16”、:alt=>“删除条目”)、phone、:confirm=>“确定吗?”、:method=>:Delete、:remote=>true、:class=>“删除电话”)%>
在我看来。现在,一切都很好,我需要它做什么就做什么,但是当我把鼠标悬停在图标上时,它不会显示任何文本。我试过Firefox和Chrome

还有其他人遇到过同样的问题吗


谢谢

悬停图像上的
标题
文本显示在工具提示中


Alt
文本适用于禁用图像(或连接缓慢)和搜索引擎的用户

我不知道Ruby,但您需要在HTML中使用title属性来获取大多数浏览器中显示的滚动文本。。这有帮助吗

乙二醇


使用title,而不是alt,您的问题将得到解决!Alt表示可访问性-它表示“备用”。标题是工具提示的内容。

#protip-为所有图像添加
Title
s可能是一个痛苦的(非常不枯燥的)练习。为了减少痛苦,我所有的应用程序都附带了这个JS(需要):


这将不带
标题的任何
img
标题设置为其
alt
属性的值。

使用标题选项在rails 3中显示文本

<%= image_tag 'Profile.png',:title => 'Profile'  %>
”配置文件“%”

当鼠标悬停在Profile.png上时,当您在web浏览器中查看HTML源代码时,它将显示文本Profile

,ALT标记是否存在?如果是这样,你也可以考虑使用标题属性。这是一个很棒的小脚本,谢谢。
$(function() {
  $('img').each( function() {
    var o = $(this);
    if( ! o.attr('title') && o.attr('alt') ) o.attr('title', o.attr('alt') );
  });
});
<%= image_tag 'Profile.png',:title => 'Profile'  %>