Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 创建可以使用jquery node.js模块操作的html文档_Javascript_Jquery_Node.js - Fatal编程技术网

Javascript 创建可以使用jquery node.js模块操作的html文档

Javascript 创建可以使用jquery node.js模块操作的html文档,javascript,jquery,node.js,Javascript,Jquery,Node.js,我有一个来自$.ajax()请求(使用)的html字符串,我想从中提取数据。从自述文件中的文档可以看出,var$=require('jquery')创建一个空的html文档。是否可以将该DOM替换为html字符串,以便您可以像处理典型网站一样使用jQuery进行交互?当然可以: var $ = require('jquery'); $.get(URL, function(html) { var $doc = $(html); $doc.find('a').each(function(

我有一个来自
$.ajax()
请求(使用)的html字符串,我想从中提取数据。从自述文件中的文档可以看出,
var$=require('jquery')创建一个空的html文档。是否可以将该DOM替换为html字符串,以便您可以像处理典型网站一样使用jQuery进行交互?

当然可以:

var $ = require('jquery');

$.get(URL, function(html) {
  var $doc = $(html);
  $doc.find('a').each(function(i, el) {
    console.log('href', $(el).attr('href'));
  });
});