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
https://forums.phpfreaks.com/topic/221181-check-if-the-image-is-clicked/
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>

Archived

This topic is now archived and is closed to further replies.

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