Jump to content

check if the image is clicked


esandra

Recommended Posts

if this image is clicked:

<img src="images/del.png" width="15" height="15" onclick="hide(<?php echo $y;?>)">

 

this image should appear:

<img src="images/undo.png" width="20" height="20" onclick="show(<?php echo $y;?>)" title="undo">

 

2nd image won't replace the first one, it will appear somewhere else

Link to comment
Share on other sites

Here is a simple example with buttons instead of images. You could easily change the buttons for images.

<script type="text/javascript">
window.onload = function() {
// fetch delete button from DOM using
var deleteButton = document.getElementById('delete_button');
// fetch undo button from DOM wich is hidden using CSS
var undoButton = document.getElementById('undo_button');

// set onclick event for the delete button
deleteButton.onclick = function() {
	// set the style to inline of the undo button so its not hidden any more
	undoButton.style.display = 'inline';
}
}
</script>
<button id="delete_button">Delete</button>
<button id="undo_button" style="display:none;">Undo</button>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.