Santosh Santosh - 2 months ago 13
Javascript Question

icon change onclick of menu element jquery

I am trying to replace the calendar icon which is on right side of header,based on item we selected from the menu elements.

$(document).ready(function() {
$('ul.s-thumbs li').on('click', function() {
var getClass = $(this).attr('class');
$("#title").text(getClass);
});
});


Please check full code here

Answer

You can do it like this

    $(document).ready(function() {

  $('ul.s-thumbs li').on('click', function() {
    var getClass = $(this).attr('class');
    $("#title").text(getClass);
    classI= $(this).find("i").attr('class');
    $("#chicon i").attr("class",classI+" pull-right");
  });
});

Here is working example http://codepen.io/anon/pen/ALWRww