View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial How to check if an id exists using jQuery

How to check if an id exists using jQuery

Below is a simple function that can tell you if a specific ID exists or not :

function id_exists(id)
{
	if ($("#"+id).length == 0)
	{
		return false;
	}
	return true;
}

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

Rating: (0+, 0-) In: jQuery