how to get html content of <li> among the ajax <li> items
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);
精彩评论