Use a dot in a class name within jquery: $('.B.Avf').toggle();

前端 未结 2 783
陌清茗
陌清茗 2021-01-23 01:17

Is it possible to use a dot in a classname inside Jquery?

$(\'.B.Avf\').toggle();

I need to keep the dot in: B.Avf classname.
Can i som

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-23 01:28

    You can always just use the [attr="val"] selector for this.

    $('[class*="B.Avf"]')
    

    The *= means "class contains...". Since this is looking at the attribute directly and there could be more than one class, you don't want to use =.

提交回复
热议问题