Solved

jquery click not working on data attribute

Posted on 2013-11-29
2
218 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
2 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 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 250 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now