Select all elements with class name start by specific string by jquery

后端 未结 2 1749
南方客
南方客 2021-01-07 12:06

This is my HTML DOM:

Goola1

volaa
相关标签:
2条回答
  • 2021-01-07 12:45

    To target elements with multiple classes, where one of then starts by "yak-bak" at the beginning of the attribute class, or at the middle of it, you can use:

    JQUERY

    $("div[class^='yak-bak'],div[class*=' yak-bak']").parent('div').remove();
    

    This will select elements where the class starts by "yak-bak" and elements that contain a class stated by "yak-bak".

    0 讨论(0)
  • 2021-01-07 12:54
    $('div').filter(function() {
      return $(this).has('span[class^="yak-bak"]');
    }).remove();
    

    DEMO

    Or

    $('div').filter(function() {
      return $(this).has('span[class^="yak-bak"], span[class*=" yak-bak"]');
    }).remove();
    

    But First one will enough.

    0 讨论(0)
提交回复
热议问题