简体   繁体   English

JQtouch事件?

[英]JQtouch event?

I'm trying to call a function on click of class djl but I don't know what's wrong. 我试图在单击类djl调用一个函数,但我不知道怎么了。 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". 我怀疑在绑定时没有与选择器“ a.djl”匹配的元素。 If so you need to use the live event for binding: 如果是这样,则需要使用实时事件进行绑定:

$("a.djl").live("click", function(){
  //your stuff to do
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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