Reputation: 1042
I am new to web development and to get my some knowledge on this, I am working on a project https://jsfiddle.net/pz6tc3ae/30/ (Please try the project in chrome, some features don't work in other browsers). There are two tables in this project and on click on any cell in table 1, it triggers table 2 and if user clicks on an option in table 2, it changes the colour of clicked cell in table 1.
What I want to do is, add a feature in table 1 that when user clicks 3 times on a cell in table 1 the colour of the cell changes to a specfic/default colour.
I have done some research but being new to javascript and html5, I am not quite sure how to implement my research into the project I am working on, so any help is welcomed.
For example, reading on w3school: http://www.w3schools.com/tags/ev_ondblclick.asp I found double click function
<button ondblclick="myFunction()">Copy Text</button>
<script>
function myFunction() {
document.getElementById("field2").value = document.getElementById("field1").value;
}
</script>
Also, there was a useful answer given by Andy E on How do I listen for triple clicks in JavaScript? but I am not sure how to go about putting this in my project.
Thanks in advance and if my question was not clear please let me know.
Upvotes: 0
Views: 118
Reputation: 1042
Based on @Ryan.Hunt comment/help I was able to solve my problem using this:
if (evt.detail === 3) {
actionCell.style.background = '#000000';
}
https://jsfiddle.net/5xrqpggh/
I hope it will help future readers.
Upvotes: 0