How do I detect if something is being clicked in JavaScript? (without using jQuery) [duplicate]
问题 This question already has answers here : JavaScript event registering without using jQuery (6 answers) Closed 6 years ago . I would like to create a boolean function that can detect whether a certain element is being clicked and then output true or false. I want to do this in pure JavaScript with no jQuery, and my idea looks something like this: function clicked(whatever-element-I-want) { if(whatever-element-I-want==clicked) { return true; } else { return false; } } I know this question