How can I make a button change its position after being clicked?

css, html, javascript

Solution

You need to use JavaScript:

var d = document.getElementById("button");
d.addEventListener('click',function(){
    d.className = d.className + " move";
});

Demo: http://jsfiddle.net/LJHQW/3/

Or, if you're already using jQuery:

$('.button').click(function(){
    $(this).addClass('move');
});

Demo: http://jsfiddle.net/LJHQW/1/

Problem

How can I make a button change its position after being clicked like this demo here but instead of the active parameter I would like it to be at `margin-left:50px;` definitely after clicked HTML ``` <div class="button"> <button type="fb-like">Fb-Like</button> </div> ``` CSS ``` .button:active { margin-left:50px; } /* But with a on clicked parameter instead of active */ ```

Original source

Related problems