关于js的问题,想实现以下功能,求各位大神伸出援助之手

怎样实现点击一个图标,选中,再次点击时取消,再次点击又选中,循环的

使用前请导入jquery
.selected{
border:1px;
}

<br> $(&quot;img&quot;).on(&quot;click&quot;, function(){<br> $(this).toggleClass(&quot;selected&quot;);<br> });<br> <script></p>