1. Determine whether the form element exists (1)
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->if("periodPerMonth" in document.theForm)
{
return true;
}
else{
return false;
}
2. Determine whether the page element exists
if(document.getElementById("XXX"))
{
//Exists
}
3. Determine whether the form element exists (2)
if(document.theForm.periodPerMonth)
{
//Exists
} or
if(typeof(document.theForm.periodPerMonth) == "object")
{
//Exists
}
4. Determine whether the form exists
if(document.theForm)
{
//Exists
}
5. Write a script with Jquery
if ( $("#someID").length > 0 ) {
$("#someID").text("hi");
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn