M

(jQuery) serializeObject 본문

JavaScript

(jQuery) serializeObject

M_master 2022. 2. 23. 09:20
jQuery.fn.serializeObject = function() {
    var obj = null;
    try {
        if (this[0].tagName && this[0].tagName.toUpperCase() == "FORM") {
            var arr = this.serializeArray();
            if (arr) {
                obj = {};
                jQuery.each(arr, function() {
                    obj[this.name] = this.value;
                });
            }
        }
    } catch (e) {
        alert(e.message);
    }
 
    return obj;
};
728x90

'JavaScript' 카테고리의 다른 글

reduce()  (0) 2022.05.11
Promise  (0) 2022.02.24
table excel download  (0) 2022.02.23
화면 프린트 기능  (0) 2022.02.18
배열 관련 함수  (0) 2019.10.04