0

我有一个带有图像标签的 link_to_function。我想禁用它(使其图像模糊 n 禁用单击事件)以进行页面加载。但是单击名为“button 1”的另一个按钮,然后才应该启用它。我怎样才能完成它?

带有链接的图像的CSS是

.img  
{
opacity:0.4;
filter:alpha(opacity=40); 
} 

视图是....

<%i = 1%>
<div id = "file_<%= i %>" class = "file">
<%= link_to_function image_tag("play_images.png",:width => 30, :height => 30,:align => 'left', :title => 'Play', :id => "img_play#{i}"), :id => "play_#{i}"%>
&nbsp;&nbsp;<%= link_to_function image_tag("stop_images.png",:width => 30, :height => 30,:align => 'left', :title => 'Stop', :id => "img_stop#{i}",:class => "img"), :id => "stop_#{i}"%>
<%= link_to_function image_tag("fast_fwd.jpeg",:width => 30, :height => 30, :title => 'Fast farword', :id => "img_ff#{i}", :class => "img"), :disabled => 'true',:id => "ff_#{i}"%>

<%= link_to_function image_tag("images.jpeg",:align => 'right'), :id => "close_#{i}"%>
 <div id = "request_<%= i%>" class = "request">
   </div>
 </div>
 <%i = i + 1%>

现在,我想要的最初是 2 个带有“img”类的图像按钮将被模糊和禁用,当我点击 id 为“play_#”的按钮时,两个带有“img”类的按钮都将删除它们的类,它们将b 启用。那么如何让它们在加载时禁用并在单击播放按钮时启用。我的jquery是...

   function set_file(id,time,user,node,activity)
    {
     var filename = "";
       filename = user+"_"+node+"_"+activity+"_"+time;

        jQuery("#log_"+id).ready(function() {
        jQuery("#file_"+id).dialog({modal: true, resizable: false, draggable: false,
                 title: "File Content", width: 520,

       });
        jQuery("#play_"+id).click(function(){
          jQuery("#img_stop"+id).removeClass();
          jQuery("#img_ff"+id).removeClass();
                    text="content of text here";
                    delay=500;
                    currentChar=1;
                    destination="[not defined]";
       jQuery.get('/requests/download_log/?filename=' + filename, function(data) {
    });

});
jQuery("#stop_"+id).click(function(){
    jQuery("#img_ff"+id).addClass('img');
    jQuery("#img_stop"+id).addClass('img');
   alert("Stop");
  });
   jQuery("#ff_"+id).click(function(){
  alert("Fast Forward");
  });
 }
4

2 回答 2

0

请更准确地描述您的问题,例如发布一些代码。

也许你尝试做这样的事情:

jQuery(document).ready(function() {
    var $button1 = jQuery('#button1');
    var $button2 = jQuery('#button2').attr('disabled', 'disabled');

    $button1.click(function() {
        if ($button2.is(':disabled')) {
            $button2.removeAttr('disabled');
        } else {
            $button2.attr('disabled', 'disabled');
        }
    });

    $button2.click(function() {
        alert('button2 - click');
    });
});​

在这里试试:http: //jsfiddle.net/f9F9z/2/

于 2012-12-13T10:39:36.777 回答
0

如果我对您的理解正确,那么您在这里有几种可能性。最常见的一种是最初使用 css display:none 不显示按钮。您可以在准备好文档时将显示设置为阻止或删除 css。如果您单击“按钮 1”,则可以使用相同的功能。

如果有另一种方法,您应该发布一些代码,以便我们查看是否有更合适的方法来执行此操作。

于 2012-12-13T10:42:26.390 回答