Replace Div Content onclick

前端 未结 6 1014
名媛妹妹
名媛妹妹 2020-12-06 07:48

I know nothing about jQuery but want to achieve something really important.

I want to have a button/link that will replace the div content and if I press that button

6条回答
  •  孤街浪徒
    2020-12-06 08:09

    A simple addClass and removeClass will do the trick on what you need..

    $('#change').on('click', function() { 
      $('div').each(function() { 
        if($(this).hasClass('active')) { 
            $(this).removeClass('active');
        } else { 
            $(this).addClass('active');
        }
    });
    

    });

    Seee fiddle

    I recommend you to learn jquery first before using.

提交回复
热议问题