?
Solved

jquery click not working on data attribute

Posted on 2013-11-29
2
Medium Priority
?
234 Views
Last Modified: 2013-12-01
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
Comment
Question by:stargateatlantis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 1000 total points
ID: 39686045
Code works fine
http://jsfiddle.net/GaryC123/PH6RZ/2/

Have you included jQuery?
Is the code inside a document ready block?
0
 
LVL 12

Accepted Solution

by:
zappafan2k2 earned 1000 total points
ID: 39686269
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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question