Reputation: 105
I'm hoping this is quite simple but I'm looking to activate a specific button after I click a certain element on the page.
So far, I've looked at the button's class and added a .click function but unfortunately, this isn't working.
Any suggestions would be most welcome.
Note* This button hasn't got a url contained in the link but activates a slider.
Amended Code
$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();
});
});
Upvotes: 1
Views: 1791
Reputation: 5594
Firstly disable the button on load then enable it when a link is clicked
$(document).ready(function(){
$('#buttonID').attr("disabled","disabled");
$('.certainElement').click(function(e){
$('#buttonID').removeAttr("disabled");
});
});
Upvotes: 1
Reputation: 1014
Your question is a bit unclear - are you wanting to click on a Div element (for example), and have that click behave as if you have clicked on a button (or similar)? If so, try
Edit: just seen your comment on the other answer. Think this should do:
$("#button1").click(function() {
$("#button2").click();
});
Upvotes: 2
Reputation: 9190
I don't know what you mean by "activate", so I've just made a button be visible, assuming it was previously hidden. Substitute the show function for whatever you like.
$("#idOfOtherElement").click(function(){
$("#idOfButton").show();
});
Upvotes: 0
Reputation: 12566
See this Fiddle:
// html
<button id="first">Test</button>
<br />
<button id="second" disabled>Test 2</button>
// js
$("#first").click(function(){
$("#second").attr("disabled", false);
});
Edit: Update 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();
});
Upvotes: 0