dynamically add listener to ajax created content in jQuery

后端 未结 6 1393
死守一世寂寞
死守一世寂寞 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条回答
  •  萌比男神i
    2021-01-06 10:32

    Maybe a late and duplicate answer but This may be a late but this is what I do when I need ajax.

    $(document).ready(function () {
    $(document.body).on('click', '.Selector_S', function () { function_F(event, this) })
    }
    
    function function_F(event, d){
    ...do sth here...
    }
    

    And you dont need to reinitiate event listeners at all or write anything in ajax function.

提交回复
热议问题