Using selectors and $(this) in Jquery Ajax response

前端 未结 4 1827
暗喜
暗喜 2021-01-15 01:39

I am wondering how I use Jquery selectors within the Ajax response. My site has a feed and each main block has a unique ID, but I dont want to uniquly ID every div thats wit

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 02:20

    I assume you're referring to referencing this in a callback function. You can do something like this:

    $('#stuff').click(function() {
        var $this = $(this);
        $.get('...', function() {
            //do stuff with $this
        });
    });
    

提交回复
热议问题