简体   繁体   中英

JQtouch event?

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.

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
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM