I want to change the ADD text of the following button into "REMOVE" when clicking the button.
<input class="btn btn-6d" ahref="www.test.com" type="button" value="ADD"/>
I used the following jquery code for this:
$(':input[type="button"][class="btn-6d"]').click(function(){
var $this = $(this);
$this.toggleClass('btn-6d');
if($this.hasClass('btn-6d')){
$this.value('ADD');
} else {
$this.value('REMOVE');
}
});
I'm probably doing something wrong with my selectors but I'm relatively new to programming and can't figure out what I'm doing wrong.
Here is a fiddle for you to play with:
http://jsfiddle.net/stijn777/shzuwu0v/
Thanks in advance,
Stijn