If 4th slide active, do this (jQuery)

On click of a button, if the 4th slide in a slider is currently active, I’d like to run a simple function (changing a text value). Here’s my code:

$(".button").on('click', function() {
      if  ($('.w-slide:eq(4)').hasAttribute("aria-hidden")) {
      } 
      else {
            $('.text').text("success").val();
}});

Anyone know why this isn’t working? Should be fairly straightforward but I’ve had no luck so far.

The issue with your code is that hasAttribute is a native JavaScript method and is not part of the jQuery library. Therefore, it cannot be directly called on a jQuery object. To fix this, you can use the .attr() method provided by jQuery to check if the attribute exists.

Works great now, thanks Jeff!