Jump to content

Help in IF..


mowais
 Share

Recommended Posts

Can anyone Plz help me in Javascript. I am trying to make a puzzle game in Javascript but it's not running. Here is the coding..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Puzzle Game</title><style type="text/css">img{position:absolute;}#owais{left:39px;top:44px;}#kalam{left:101px;top:44px;}</style><script type="text/javascript">function puzzle(){  if(document.getElementById('owais').style.left == parseInt(62 + document.getElementById('kalam').style.left))   {	document.getElementById('owais').style.left = '101px';	document.getElementById('kalam').style.left = '39px';   }}</script></head><body><img src="Bair.jpg" width="61" height="60" alt="Bair1" id="owais" onclick="puzzle();"/><img src="Bair2.jpg" width="61" height="60" alt="Bair2" id="kalam"/></body></html>

Plz Help me about this coding..When i given this condition out of if it is running..

Edited by mowais
Link to comment
Share on other sites

what is the problem? you should debug the values you are expecting to be testing for. The issue is that CSS not set inline isn't available in an elements style property. Try googling for how to get an elements style object and properties through JS.

Edited by thescientist
Link to comment
Share on other sites

that's one way. or per my comment, you can use javascripthttps://www.google.com/#hl=en&safe=off&tbo=d&sclient=psy-ab&q=get+css+styles+javascript&oq=get+css+styles+j&gs_l=hp.3.0.0i30l2j0i8i30l2.1302.8283.0.9099.42.24.13.5.7.0.201.2434.16j7j1.24.0.les%3B..0.0...1c.1.u84zxcxNtE8&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&fp=dd0ccaa9b058d0aa&bpcl=38625945&biw=1440&bih=779

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...