dynamically add listener to ajax created content in jQuery

后端 未结 6 1357
死守一世寂寞
死守一世寂寞 2021-01-06 10:02

I am trying to get the html value of a linked clicked. The links are created dynamically with Ajax so I don\'t think .bind will work and I don\'t have latest version with

6条回答
  •  悲&欢浪女
    2021-01-06 10:10

    You should really be using the latest version if you can help it.

    If it's the ".doYouMean" elements that are added using AJAX, and #message is always there, try:

    $('#message').bind('click', function (event) {
      var target = event.currentTarget;
      if ($('.doYouMean').filter(target)) {
        // target is the .doYouMean that was clicked: Handle here
      };
    });
    

    (This works: http://www.jsfiddle.net/SuVzv/)

提交回复
热议问题