| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

DOM元素查找高亮库:highlighter.js

Highlighter.js是一个迷你纯JavaScript库,能够让轻松查找,选择和高亮DOM元素。

document.addEventListener("DOMContentLoaded", function() {     var Highlighter = new window.Highlighter();      Highlighter.next('<div>');    Highlighter.underline(); window.console.log('Highlighter underlined this element:', Highlighter.element);  });

Demo

Live demo

Commands

Select Next

Select next element starting from the current selected element (by default is the first DOM element)

Highlighter.next();

Select Previous

Select previous element starting from the current selected element ( by default is the first DOM element)

Highlighter.previous();

Skip Next

Skip a bunch of next elements starting from the current selected element

Highlighter.skipNext(50);

Skip Previous

Skip a bunch of previous elements starting from the current selected element

Highlighter.skipPrev(35);

Underline

Highlight the current selected element

Highlighter.underline();

Erase

Remove highlighting from the current selected element

Highlighter.erase();

Select Next by ID

Select next element (by ID) starting from the current selected element (by default is the first DOM element)

Highlighter.next('#test');

Select Next by class/es

Select next element (by class/classes) starting from the current selected element (by default is the first DOM element)

Highlighter.next('.class .class-2');

Select Next by < tag > name

Select next element (by < tag > name) starting from the current selected element (by default is the first DOM element)

Highlighter.next('<span>');

Select Previous by ID

Select previous element (by ID) starting from the current selected element (by default is the first DOM element)

Highlighter.previous('#test');

Select Previous by class/es

Select previous element (by class/classes) starting from the current selected element (by default is the first DOM element)

Highlighter.previous('.class .class-2');

Select Previous by < tag > name

Select previous element (by < tag > name) starting from the current selected element (by default is the first DOM element)

Highlighter.previous('<span>');

Select Element By ID

Select first element in the DOM by ID

Highlighter.select('#id');

Select Element by class/es

Select first element in the DOM by class or classes

Highlighter.select('.class .class2');

Select Element by tag name

Select first element in the DOM by < tag > name

Highlighter.select('<span>');

项目主页:http://www.open-open.com/lib/view/home/1438503379920

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1438503379920.html
JavaScript开发工具包 highlighter.js