$('button').on('click', function() {
// DOM 한번 탐색
$('.modal').modal();
// DOM 다시 한번 탐색
$('.modal').addClass('active');
// DOM 또 다시 한번 탐색
$('modal').css(...);
});
$('button').on('click', function() {
// DOM 한번만 탐색 (체이닝)
$('.modal')
.modal()
.addClass('active')
.css(...);
});
$('button').on('click', function() {
// DOM 한번만 탐색 (캐시)
var modal = $('.modal');
modal.modal();
modal.addClass('active');
modal.css(...);
});
var first = $('.first');
var second = $('.second');
var value = $first.val();
var $first = $('.first');
var $second = $('.second');
var value = $first.val();
var first = $('.first');
var second = $('.second');
var value = $first.val();
var $first = $('.first'),
$second = $('.second'),
value = $first.val();
$second.html(value);
$second.on('click',function(){
alert('hello everybody');
}).fadeIn('slow').animate({height:'120px'},500);
$second
.html(value)
.on('click',function(){alert('hello everybody');})
.fadeIn('slow')
.animate({height:'120px'}, 500);
function initVar($myVar) {
if(!$myVar) {
$myVar = $('.selector');
}
}
if ( collection.length > 0 ) {}
function initVar($myVar) {
$myVar = $myVar || $('.selector');
}
if ( collection.length ) {}
var $container = $('.container'),
$containerLi = $('.container li'),
$containerLiSpan = $('.container li span');
var $container = $('.container '),
$containerLi = $container.find('li'),
$containerLiSpan = $containerLi.find('span')