[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

jquery click not working on data attribute

How come the following isn't working

<a href="#lnk" data-toggleIssue="details" data-issueid="1">

  $('a[data-toggle="details"]').click(function(){
        alert('eeeee');
    });

Open in new window

0
stargateatlantis
Asked:
stargateatlantis
2 Solutions
 
GaryCommented:
Code works fine
http://jsfiddle.net/GaryC123/PH6RZ/2/

Have you included jQuery?
Is the code inside a document ready block?
0
 
zappafan2k2Commented:
Hmm.  The code you've shown will not match the element.
Your jQuery is looking for elements with attribute data-toggle="details", but your HTML shows an element with attribute data-toggleIssue="details".

In other words, they should both be either data-toggleIssue or data-toggle.  Better yet, give the elements a unique dummy class, which will be slightly faster.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now