שלח תשובה

זירת השאלות

1126
צפיות
1
תשובות

בדיקת ID תקין

,‏ 26 ביולי, 2006

אני מריץ סקריפט שבודק אם ID מסוים קיים אם כן אז שיציג את הDIV עם
הID התקין וכל שאר הID שהם לא תקינים שלא יציג אותם אך משום מה הסקריפט
מקפיץ לי שגיאה ולא עובד.

הינה הקוד:




<html>
<head>
<style>
.test
{
color:red;
}
.non
{
color:red;
}
</style>
<script>

function checkClas()
{
    crtClas = document.getElementById('test');
    if(document.getElementById !="test")
    {
    document.getElementById(!='test').display="none";
    }
}

</script>
</head>
<body onload="checkClas()">
<table border="0">
    <tr>
    <td>
    <div id="test" class=test style="background:red; width:250; height:250; display:;">
    </div>
    </td>
    <td>
    <div id="non" class=non style="background:green; width:250; height:250; display:;">
    </div>
    </td>
    </tr>
</table>


</body>
</html>



אשמח לקבל תיקון ומודה מראש על העזרה.

תגיות:

1 תשובות

  1. התנאי שלך לא נכון
    מספיק שתעשה

    if(document.getElementById("test"))

שלח תשובה