簡體   English   中英

jQuery選擇器以加載Ajax內容

[英]jQuery selector for ajax loaded content

我已經使用了這個庫: http : //www.jacklmoore.com/autosize/

為了使用它,我應該使用如下語法:

autosize($('textarea#description'));

或任何其他JavaScript選擇器。 但是我的textarea由ajax加載,無法正常工作。

是否還有其他可用於ajax元素的選擇器? 謝謝

只需將jquery選擇器包裝起來,然后使用.find()縮小范圍即可。

$.ajax({...}).done(function(responseHTML){
    // depending on what the function is doing you may need to append it to the body first.
    $(responseHTML).appendTo('body'); // or wherever you want to put it
    $textarea = $(responseHTML).find('#description');
    autosize($textarea);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM