开发者

how to get html content of <li> among the ajax <li> items

开发者 https://www.devze.com 2023-02-26 05:34 出处:网络
usi开发者_开发百科ng ajax i am returning set of list items all with different ids . i want to get the html content of one particular list item . i even have the id . but i couldnt get the html content

usi开发者_开发百科ng ajax i am returning set of list items all with different ids . i want to get the html content of one particular list item . i even have the id . but i couldnt get the html content with this

var li_element = $(req_id).html();
$('.selected_res_cls').append(li_element);


Should use # to select on ID

var li_element = $("#" + req_id).html();
$('.selected_res_cls').append(li_element);


Is your req_id variable prefixed with a hash, i.e. where <li id="id1234"> you should be using $('#id1234')


can't you just:

 $('.selected_res_cls').append($(req_id));


Try this

var li_element = $("#"+req_id).text();

$('.selected_res_cls').append(li_element);

0

精彩评论

暂无评论...
验证码 换一张
取 消