我从ASP.MVC获得了一串HTML内容,作为部分视图返回。我不想在页面的任何地方呈现这个内容,而是希望使用JQuery从返回的HTML内容中选择某些元素,并使用它进行操作。
在不将JQuery呈现在页面上的情况下,是否可以这样使用HTML选择器?
发布于 2013-10-25 01:23:42
可以,停那儿吧。
var html = '';
var $html = $(html);
//then do normal stuff with $html like
$html.find('input[name="x"]').val();//will get the value of the input with name x
$html.find('.tester').text();//will get the text content of element with class testerhttps://stackoverflow.com/questions/19579538
复制相似问题