I have below code and i want to have default input type button when second clicked
$(function () {
$('.inputbutton').on('click', function (e) {
e.preventDefault();
$(this).css("background-color", "gray");
});
});
As I understand, you just want to remove the inline CSS you add when clicked?
Why don’t you toggle a class on the button and style via external Stylesheet?
In you CSS of course you would have to style the class accordingly
If you really want to stick with your “inline styles added via javascript” solution, just check if the style attribute is set and if so, remove it using .removeAttr()
In my opinion styles belong in a stylesheet and not in a javascript file. (Of course there are exceptions to this rule)