title: How can this be done in the shortest way?
body: <p>I have saved the <code>class</code> holding the position of the <code>i</code> element in the <code>a</code> that is clicked by the user. When the <code>a</code> tag is clicked, I want to get the value of its <code>attr</code> and add it as a class to the <code>i</code> element tag. I have tried doing it as illustrated below but I feel like this to much code. How can this be done in the shortest wat possible?  </p>
  
  <pre><code>    &lt;i id="pps_ToggledIcon" class="pisp_p pISImage"&gt;&lt;/i&gt;
  
      &lt;li class="privListItem checkedList selectedList li_public"&gt;
          &lt;a href="/p" class="psLink" title="pisp_p"&gt;
              &lt;span class="privLabel"&gt;PP&lt;/span&gt;
          &lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="privListItem checkedList selectedList li_public"&gt;
          &lt;a href="/f" class="psLink" title="pisp_f"&gt;
              &lt;span class="privLabel"&gt;F&lt;/span&gt;
          &lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="privListItem checkedList selectedList li_public"&gt;
          &lt;a href="/o" class="psLink" title="pisp_o"&gt;
              &lt;span class="privLabel"&gt;O&lt;/span&gt;
          &lt;/a&gt;
      &lt;/li&gt;
  </code></pre>
  
  <p>Here is the JS</p>
  
  <pre><code>    $(".xyp li a").on("click", function(e) {
         var pIcnSltd = $(this).attr("title"); 
         var pTIcn = $("#pps_ToggledIcon");
         if (pTIcn.hasClass("pisp_f") || pTIcn.hasClass("pisp_o")) {
              pTIcn.removeClass("pisp_f");
              pTIcn.removeClass("pisp_o");
              pTIcn.addClass("pisp_p");
          }
          else if (pTIcn.hasClass("pisp_p") || pTIcn.hasClass("pisp_o")) {
              pTIcn.removeClass("pisp_p");
              pTIcn.removeClass("pisp_o");
              pTIcn.addClass("pisp_f");
          }
          else if (pTIcn.hasClass("pisp_p") || pTIcn.hasClass("pisp_f")) {
              pTIcn.removeClass("pisp_p");
              pTIcn.removeClass("pisp_f");
              pTIcn.addClass("pisp_f");
          }
      });
  </code></pre>