JQuery access dynamically created objects

后端 未结 3 1863
梦如初夏
梦如初夏 2021-01-28 05:41

How can I acceess objects(divs) that were dynamically generated. I mean DIVS that were not present in output when $(document).ready(function() started.

If I

3条回答
  •  深忆病人
    2021-01-28 06:22

    Create the div explicity and assemble its attributes and events before you append it.

    var $div = $('
    ').append('can you click on me?').attr('id', 'clicker2').click(function() { alert('hurray, it works'); }); $('#container').append($div);

提交回复
热议问题