SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking whether a image is click... how?

    hi, i wish to know how can i check whether an image which use as a button is clicked..

    is there any isset(document.getElementById('img1').value) or XXXXXXXXXXX.click==true???
    newbie...really need your guidance......

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there...XXXXXXXXXXX.click==true???
    No but you can create a property like that yourself:
    Code:
    <html>
    <head><title></title>
    <script type="text/javascript" >
    
    window.onload=function()
    {
    	document.getElementById("myDiv").onclick = doSomething;
    	document.getElementById("myButton").onclick = function ()
    	{
    		if(document.getElementById("myDiv").wasClicked)
    			alert("Yep!");
    		else
    			alert("Not yet.");
    	}
    };
    
    
    function doSomething()
    {
    	alert("Hey, you clicked me.");
    	this.wasClicked = true;  
    }
    
    </script>
    </head>
    
    <body>
    
    <div id="myDiv">click me</div>
    
    <div>
    <input type="button" id="myButton" value="was it clicked?"/>
    </div>
    
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •