Reputation: 77
I'm trying to call a function on click of class djl
but I don't know what's wrong. It's not working.
Here is my code:
$("a.dj").click(function(){
$.getJSON("http://sdsdds.com/sds.json",function(result){
$.each(result, function(i, field){
$("ul#alb").append("<li><a class='djl' href='#songs'>" + field.name + "</a></li>");
The above code works perfect but problem starts here:
$("a.djl").click(function(){
$('#songs').replaceWith('<div>fnuh</div>');
Help me out please.
Upvotes: 1
Views: 388
Reputation: 7985
I suspect at the time of binding there is no element matchting the selector "a.djl". If so you need to use the live event for binding:
$("a.djl").live("click", function(){
//your stuff to do
});
Upvotes: 1