컴퓨터/jQuery
[jQuery] each function(for 대신 $(대상이 되는 selector).each)
수제녹차
2020. 2. 4. 19:38
728x90
반응형
* do something for every element returned from selector
$(document).ready(function(){
$('#items').on("click", function(){
$('.progress-bar').each(function() {
var randomPct = Math.round(Math.random() * 100);
$(this).attr("aria-valuenow", randomPct);
$(this).css("width", randomPct = "%");
$(this).text(randomPct);
})
})
})
반응형