How to remove class from all elements jquery

后端 未结 6 1268
野性不改
野性不改 2021-01-31 23:58

I am changing the class of an element with the following

  $(\"#\"+data.id).addClass(\"highlight\")

Given the list below.

 <         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 00:44

    This just removes the highlight class from everything that has the edgetoedge class:

    $(".edgetoedge").removeClass("highlight");
    

    I think you want this:

    $(".edgetoedge .highlight").removeClass("highlight");
    

    The .edgetoedge .highlight selector will choose everything that is a child of something with the edgetoedge class and has the highlight class.

提交回复
热议问题