How can I get the ID of an element using jQuery?

后端 未结 19 2876
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 11:57

Why doesn\'

19条回答
  •  礼貌的吻别
    2020-11-22 12:23

    $.fn.extend({
        id : function() {
            return this.attr('id');
        }
    });
    
    alert( $('#element').id() );
    

    Some checking code required of course, but easily implemented!

提交回复
热议问题