Use JQuery
<script>
function setColor(e) {
var target = e.target,
status = $(e.target).hasClass('btn-success');
$(e.target).addClass(status ? 'btn-default' : 'btn-success');
$(e.target).addClass(status ? 'btn-success' : 'btn-default');
}
</script>
Also remember that once a class is assigned the class exists on that element during runtime. Removing a class is something to be added i think.
Other option is to add the button itself as an argument
<button onclick="setColor(this)" type="button" style="width: 50px; height: 50px; margin: 10px; padding: 10px 16px; font-size: 18px; line-height: 1.33; border-radius: 25px; box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);" class="btn btn-circle btn-lg"><span class="glyphicon glyphicon-search" style="margin: 0 0px;"></span></button>
<script>
function setColor(btn) {
var status = $(btn).hasClass('btn-success');
$(btn).addClass(status ? 'btn-default' : 'btn-success');
$(btn).addClass(status ? 'btn-success' : 'btn-default');
}
</script>
And to be complete i believe you want this?
<button onclick="setColor(this)" type="button" style="width: 50px; height: 50px; margin: 10px; padding: 10px 16px; font-size: 18px; line-height: 1.33; border-radius: 25px; box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);" class="btn btn-circle btn-lg"><span class="glyphicon glyphicon-search" style="margin: 0 0px;"></span></button>
<script>
function setColor(btn) {
$(btn).toggleClass('btn-success');
}
</script>