[API] toggleClass()

2015. 7. 28. 13:55[개발] 지식/Jquery

  • .toggleClass( className )

    • className
      Type: String
      One or more class names (separated by spaces) to be toggled for each element in the matched set.
  • version added: 1.3.toggleClass( className, state )

    • className
      Type: String
      One or more class names (separated by spaces) to be toggled for each element in the matched set.
    • state
      Type: Boolean
      A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
  • version added: 1.4.toggleClass( [state ] )

    • state
      Type: Boolean
      A boolean value to determine whether the class should be added or removed.
  • version added: 1.4.toggleClass( function [, state ] )

    • function
      Type: FunctionInteger index, String className, Boolean state ) => String
      A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.
    • state
      Type: Boolean
      A boolean value to determine whether the class should be added or removed.


ex)


var main = function() {
  $(".btn").click(function() {
  
  $(".btn").toggleClass('btn-like');


  });
};

$(document).ready(main);

'[개발] 지식 > Jquery' 카테고리의 다른 글

find()와 children()의 작동원리  (0) 2016.11.04
이벤트 중복 바인딩 방지  (0) 2016.06.14
html()의 사용과 innerHTML  (0) 2016.06.14
[API] animate()  (0) 2015.07.27
<