我希望这很简单,但我希望在单击页面上的某个元素后激活一个特定的按钮。
到目前为止,我已经查看了按钮的类并添加了一个.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();
});
});发布于 2012-09-19 23:51:36
你的问题有点不清楚--你是否想要点击一个Div元素(例如),然后让这个点击行为就像你点击了一个按钮(或类似的按钮)?如果是这样,请尝试
编辑:刚刚看到你对另一个答案的评论。我想应该是这样的:
$("#button1").click(function() {
$("#button2").click();
});发布于 2012-09-19 23:52:41
首先在加载时禁用该按钮,然后在单击链接时启用该按钮
$(document).ready(function(){
$('#buttonID').attr("disabled","disabled");
$('.certainElement').click(function(e){
$('#buttonID').removeAttr("disabled");
});
});发布于 2012-09-19 23:48:43
参见this小提琴:
// html
<button id="first">Test</button>
<br />
<button id="second" disabled>Test 2</button>
// js
$("#first").click(function(){
$("#second").attr("disabled", false);
});编辑:更新here
// 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();
});https://stackoverflow.com/questions/12498234
复制相似问题