Voyeur

2018-07-12 admin

Voyeur是什么

什么是Voyeur,Voyeur is a tiny (1.2kb) Javascript library that lets you traverse and manipulate the DOM the way it should have been.

Voyeur介绍、Voyeur使用

<div>
	<header>
		<h1 id="title"><em><a href="/">Hello world!</a></em></h1>
	</header>
	<section>
		<ul>
			<li class="item"><a href="#">Navigation Item</a></li>
			<li class="item"><a href="#">Navigation Item</a></li>
			<li class="item"><a href="#">Navigation Item</a></li>
			<li class="item"><a href="#">Navigation Item</a></li>
			<li class="item"><a href="#">Navigation Item</a></li>
		</ul>
	</section>
</div>

</body>


```source-js
//Lets get the title link
Voyeur.div.header.h1.em.a.href = "http://google.com"
Voyeur.find("#title").em.a.innerText = "New title!";

//Let's get those navigation items
Voyeur.div.section.ul.li.use(function(li, i) {
	li.a.innerText = "Link #" + i;
});

Voyeur.div.section.ul.li.eq(3).classList.add("Highlighted!");

//How about we create some content
var content = Voyeur.create.div
	.section.mult(5).p.em.use(function(em) {
		em.textContext = "Hello world!";
	});

Voyeur.div.appendChild(content);

Usage

Install via bower (courtesy of @pid)

bower install Voyeur

Install via component

component install dunxrion/voyeur.js

Include the script somewhere on the page.

<script type="text/javascript" src="Voyeur.min.js">

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-35825.html

文章标题:Voyeur

回到顶部