[在gulp中使用jquery语法处理DOM]
Gulp plugin for generic DOM manipulation by jQuery grammar.
This Gulp plugin is a simple wrapper around jsdom and jQuery making it possible to run DOM operations on any inbound HTML by jQuery grammar.
This Gulp plugin depend on jquery, jsdom and console-color-mr。
Installation
npm install gulp-jquery-mr --save-dev
Install dependencies
npm install jquery jsdom console-color-mr --save-dev
Simple Example
const gulp = require('gulp');
const gulpJquery = require('gulp-jquery-mr');
gulp.task('handleHtml', function () {
return gulp.src('test/index.html')
.pipe(gulpJquery(function ($) {
$('#test').html('Hello Michael Ray');
}))
.pipe(gulp.dest('test/build'));
});
本文介绍了一个Gulp插件,该插件利用jsdom和jQuery简化了对HTML文件的DOM操作过程。通过简单的配置即可实现对HTML元素的选择与修改。
670

被折叠的 条评论
为什么被折叠?



