[개발] 지식/Jquery(5)
-
find()와 children()의 작동원리
$(selector).find()selector의 하위에 있는 모든 요소들을 찾는다.find()에 selector를 인풋으로 주면 자식들 중 해당 selector에 매칭되는 요소들을 jquery 객체로 돌려준다. $(selector).children()selector의 1레벨 하위에 있는 요소들을 찾는다. (직계 자식만 찾는다)find()와 마찬가지로 selector를 인풋으로 주었을 때 해당 selector에 매칭되는 요소들을 jquery 객체로 돌려준다. 두 함수 모두 매칭된 결과를 배열로 돌려준다. 따라서 돌려받은 jquery 객체안에 복수의 배열이 있을 수 있다.예를들어 $(selector).find().css('background-color','gold'); 문장을 실행하면 find()에 의해 ..
2016.11.04 -
이벤트 중복 바인딩 방지
이벤트 처리를 하다보면, 이벤트가 중복으로 발생하는 경우가 있다. 원인이야 여러가지가 있겠지만 어떤 이유가 되었든 중복으로 이벤트 바인딩이 되어 생기는 문제일 가능성이 높다. 따라서 이러한 문제를 해결하기 위해 바인딩전에 언바인딩을 해주는 습관을 들이도록 하자 _el.$listMore.unbind('click').bind('click', function (e) { e.preventDefault(); o.data.listPageCurrentIndex++; deviceCheckedDataCallEvent('__DESIGN_LIST_MORE'); }).unbind('__DESIGN_LIST_MORE_HIDE').bind('__DESIGN_LIST_MORE_HIDE', function () { $(this).p..
2016.06.14 -
html()의 사용과 innerHTML
- html(htmlCode) Set the HTML contents of each element in the set of matched elements.match된 element에 HTML Code를 넣는다 When .html() is used to set an element's content, any content that was in that element is completely replaced by the new content. Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content...
2016.06.14 -
[API] toggleClass()
.toggleClass( className )classNameType: StringOne or more class names (separated by spaces) to be toggled for each element in the matched set.version added: 1.3.toggleClass( className, state )classNameType: StringOne or more class names (separated by spaces) to be toggled for each element in the matched set.stateType: BooleanA Boolean (not just truthy/falsy) value to determine whether the class ..
2015.07.28 -
[API] animate()
.animate( properties [, duration ] [, easing ] [, complete ] )propertiesType: PlainObjectAn object of CSS properties and values that the animation will move toward.duration (default: 400)Type: Number or StringA string or number determining how long the animation will run.easing (default: swing)Type: StringA string indicating which easing function to use for the transition.completeType: Function(..
2015.07.27