gulp中使用jquery语法处理DOM

[在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'));
});

相关文档
https://www.npmjs.com/package/gulp-jquery-mr

猜你喜欢

转载自blog.csdn.net/michael51/article/details/79054039