Javascript & JQuery & CSS > jQuery ¹è¿ ó¸®
µî·ÏÀÏ : 2017-07-04 19:35
Á¶È¸¼ö : 53,696
$.grep(array, callback, [invert]) : callbackÀ» Å×½ºÆ® ÇÔ¼ö·Î »ç¿ëÇÏ¿© array¸¦ ÇÊÅ͸µ ÇÑ´Ù.
$.makeArray(object) : object¸¦ ¹è¿·Î º¯È¯ÇÑ´Ù.
$.map(array, callback) : °¢ Ç׸ñ¿¡ callbackÀ» ¼öÇàÇÑ °á°ú·Î »õ·Î¿î ¹è¿À» »ý¼ºÇÏ¿© ¹ÝȯÇÑ´Ù.
$.inArray(value, array) : value°¡ array³»¿¡ ÀÖ´ÂÁö °Ë»çÇÑ´Ù.
$.merge(array1, array2) : array1¿Í array2ÀÇ ³»¿ëÀ» ÇÕÄ£´Ù.
.unique(array) : array¿¡¼ Áߺ¹µÈ DOM ¿ä¼Ò¸¦ Á¦°ÅÇÑ´Ù.
//jQuery.each¸¦ »ç¿ëÇÏ¿© ¹è¿°ú °³Ã¼¸¦ ¹Ýº¹ÇÏ¿© ó¸®
$(document).ready(function () {
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
$.each(months, function() {
$("#months").append("<li>" + this + "</li>");
});
var days = {Sunday:0, Monday:1, Tuesday:2, Wednesday:3, Thursday:4, Friday:5, Saturday:6 };
$.each(days, function(key) {
$("#days").append("<li>" + key + " (" + this + ")</li>");
});
});
$(document).ready(function () {
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
//jQuery.grepÀ» »ç¿ëÇÏ¿© ¹è¿ ÇÊÅ͸µÇϱâ
months = $.grep(months, function(value, i) {
return ( value.indexOf('J') == 0 ); //J·Î ½ÃÀÛÇÏ´Â Ç׸ñ °Ë»ö
});
//jQuery.mapÀ» »ç¿ëÇÏ¿© ¹è¿ Ç׸ñÀ» ¹Ýº¹ÇÏ¸ç ¼öÁ¤Çϱâ
months = $.map(months, function(value, i) {
return value.substr(0,3) //óÀ½ 3±ÛÀÚ¸¸ ÃßÃâ
});
$("#months").html( "<li>" + months.join("<li>|</li>") + "</li>" );
});