How to add/remove attribute when click?
This is what I tried so far.
$('.btn').click(function() {
$(this).attr("title", "selected").siblings().removeAttr("title", "selected");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li>
<button title="selected" class="btn">click</button>
</li>
<li>
<button class="btn">click</button>
</li>
<li>
<button class="btn">click</button>
</li>
</ul>
When click button, add attribute "selected" and others remove attribute "selected".
This is DEMO, https://jsfiddle.net/a8egp275/3/
How do I need to fix it? please help.
.removeAttr()hasn't second parameter.