1

我希望这很简单,但我希望在单击页面上的某个元素后激活一个特定按钮。

到目前为止,我已经查看了按钮的类并添加了一个 .click 函数,但不幸的是,这不起作用。

任何建议都将受到欢迎。

注意* 此按钮没有包含在链接中的 url,但会激活一个滑块。

修改后的代码

$r(document).ready(function() {

      function clickme(){
        $r('.coda-nav ul li a.current').click();  
      };

      $r('#open').click(function () {
        $r('#expandable-2').show('slow');
        clickme();
      });
       $r('#close').click(function () {
        $r('#expandable-2').hide('1000');
        clickme();
      });
  });
4

4 回答 4

2

您的问题有点不清楚-您是否要单击 Div 元素(例如),并且该单击的行为就像您单击了按钮(或类似按钮)一样?如果是这样,请尝试

编辑:刚刚看到您对另一个答案的评论。认为这应该这样做:

$("#button1").click(function() {
  $("#button2").click();
});
于 2012-09-19T15:51:36.283 回答
1

首先禁用加载按钮,然后在单击链接时启用它

$(document).ready(function(){

    $('#buttonID').attr("disabled","disabled");

    $('.certainElement').click(function(e){

          $('#buttonID').removeAttr("disabled");

    });

});
于 2012-09-19T15:52:41.093 回答
0

看到这个小提琴:

// html
<button id="first">Test</button>
<br />
<button id="second" disabled>Test 2</button>​

// js
$("#first").click(function(){

   $("#second").attr("disabled", false); 

});​

编辑:在这里更新

// html
<button id="first">First</button>
<br />
<button id="second">Second</button>​

// js
$("button").click(function(){

    alert($(this).attr("id"));
});


$("#first").click(function(){

   $("#second").click();

});​
于 2012-09-19T15:48:43.163 回答
0

我不知道您所说的“激活”是什么意思,所以我只是让一个按钮可见,假设它以前是隐藏的。将show函数替换为您喜欢的任何内容。

$("#idOfOtherElement").click(function(){
    $("#idOfButton").show();
});
于 2012-09-19T15:50:30.430 回答