


jQuery method to determine whether the object with the specified id exists_jquery
May 16, 2016 pm 03:57 PMjQuery determines whether the object with the specified id exists. It only needs to determine whether the length of the object is greater than 0.
Example:
The correct way to write the judgment is as follows:
if($("#object_id").length>0) { alert('对象存在'); } else { alert('对象不存在'); }
Or directly use native Javascript code to judge:
if(document.getElementById("id")) { alert('对象存在'); } else { alert('对象不存在'); }
The above is the entire content of this article, I hope you all like it.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

In-depth analysis: jQuery's advantages and disadvantages

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute?
