How to make that when the button is clicked, the mouseEvent is a span, and not its content (pure JS only)?

  • 0
    <span class="croll-btn-icon" id="scrollBtn"><i class="fas fa-long-arrow-alt-down"></i></span>

    let scrollBtn = {
    	scrollBtn: document.querySelector('#scrollBtn'),
    	start: function() {
    		let that = this;
    		this.scrollBtn.addEventListener('click', function(e){
    	scroll: function(elem){
    		let clickElemnt =;
    JavaScript Sean Jordan, Dec 30, 2019

  • 1 Answers
  • 0
    Use e.currentTarget instead of .

    Or pass the object itself to the function, and not the event (which is more correct in my opinion): that.scroll (this.scrollBtn)

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!