Stop setInterval timer when user clicks on another DOM Element

Here is some example code I am working with. I need it so when the user clicks on an <li id="fade-button"> the interval stops.

var toggleSlide = function() {
    .add("#slider li:first")
setInterval(toggleSlide, 1000);


The setInterval method returns the id of the interval. You can store this value and use clearInterval to clear that specific interval when the element #fade-button is clicked:

Basic Example Here

var intervalId = setInterval(toggleSlide, 1000);

$('#fade-button').on('click', function () {