irpersian20
چهارشنبه 13 فروردین 1393, 10:22 صبح
سلام
این یک لامپ رو خاموش و روشن میکنه منتها میخوام بدونم این شرط if چطور کار میکنه؟
if (element.src.match("bulbon"))
این bulbon از کجا اومده ؟؟؟؟؟
<!DOCTYPE html>
<html>
<body>
<script>
function changeImage()
{
element = document.getElementById('myimage');
if (element.src.match("bulbon"))
{
element.src = "pic_bulboff.gif";
}
else
{
element.src = "pic_bulbon.gif";
}
}
</script>
<img id="myimage" onclick="changeImage()"src="pic_bulboff.gif" width="100" height="180">
<p>Click the light bulb to turn on/off the light</p>
</body>
</html>
این یک لامپ رو خاموش و روشن میکنه منتها میخوام بدونم این شرط if چطور کار میکنه؟
if (element.src.match("bulbon"))
این bulbon از کجا اومده ؟؟؟؟؟
<!DOCTYPE html>
<html>
<body>
<script>
function changeImage()
{
element = document.getElementById('myimage');
if (element.src.match("bulbon"))
{
element.src = "pic_bulboff.gif";
}
else
{
element.src = "pic_bulbon.gif";
}
}
</script>
<img id="myimage" onclick="changeImage()"src="pic_bulboff.gif" width="100" height="180">
<p>Click the light bulb to turn on/off the light</p>
</body>
</html>