JavaScript & jQuery and the use of periods

后端 未结 2 496
刺人心
刺人心 2021-01-27 15:45

I am confused when to use the period before the class names when referencing them. In this example why does the first use of the \'active-slide\' class use a period beforehand w

2条回答
  •  囚心锁ツ
    2021-01-27 16:19

    The . character is a selector. It allows you to select ALL DOM elements with that ('active-slide') class.

    The jQuery syntax $('') uses selectors to return jQuery wrapped elements.

    When you are adding/removing classes, you are not using a selector. You are literally removing a classname which is actually 'active-slide' (no .)

提交回复
热议问题