How do I make an HTML button’s onclick
event trigger one of two different functions at random?
I’m using PHP on the server, and jQuery on the client. Using this code when i click the button image nothing happens...
function a(){
alert('A got called!');
}
function b(){
alert('B got called!');
}
$('#button').bind('click', function(){
var rnd = Math.floor(Math.random() * 2);
if(rnd)
a();
else
b();
});
.........
< "base_url().'images/free.png';" rel="nofollow" border='0' align='center' alt="FREE" id="button" />