Jump to content

DIV problem [double post sorry, resolving]


vbnullchar

Recommended Posts

Well, you can use a "try and catch" statment. It's not a perfect solution but it works.

<script language="javascript">
function checkID(){
	try {
		var objID = document.getElementById(document.getElementById('input1').value).id;
		alert("ID is already in use");
		return true;
	}
	catch(e){
		alert("There is no object with this ID");
		return false;
	}
}
</script>
<div id="div1">First Div</div>
<input type="text" id="input1" value="div1" />
<button onclick="checkID();">Check if ID</button>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.