0

I want to make sure that the function below gets "attached" to the appropriate Event. The function does execute, but I can't see it in the Chrome > Global Listeners. (I assume it would be under Mouse, Click event)

/* expander control */
$().ready(function() {
  $(document).on('click', '.js-expander', function(e){
    var e =  e || event, 
        $el = $(this), 
        $content;

    e.preventDefault();

    $content = $el.parent().next('.js-expander-content')
    if ($content.length == 0)
      $content = $el.parent().parent().next('.js-expander-content')
      if ($content.length == 0)
        $content = $el.siblings('.js-expander-content');

    $content.slideToggle(150);
  })
})
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
Clay Nichols
  • 11,848
  • 30
  • 109
  • 170

1 Answers1

1

The second parameter of your .on method call is “a selector string to filter the descendants of the selected elements that trigger the event.”

This means that you won't find your click event attached to the document (global event); instead, it will be attached to each one of elements matching the selector (".js-expander").

You may want to examine the event handlers attached to each one of these elements, if there's any such element in the first place (try: console.log($(".js-expander").length); )

Locoluis
  • 784
  • 6
  • 8
  • Add a link to this answer and I'll mark you response the Answer: https://stackoverflow.com/a/25236337/4906 – Clay Nichols Jun 12 '17 at 16:43
  • Dumb question: where do I type the console.log command? (I tried in the console > prompt, but got a syntaxerror : unexpected token. – Clay Nichols Jun 12 '17 at 16:46