how to check if div has id or not?

后端 未结 6 561
one
6条回答
  •  独厮守ぢ
    2021-01-12 13:02

    var $this = $(this);
    if (typeof $this.attr("id") != "undefined" && $this.attr("id").length > 0) {
        ...
    }
    

    If you're going to use $(this) more than once, it's advised to find it once, and put the resulting jQuery object in a local variable.

提交回复
热议问题