@8area8/domstrict 中文文档教程
domstrict
“getElement”和“querySelector”方法的包装器。 返回元素或错误。
News
为 query 和 queryAll 添加 $base
参数。 Todo:创建测试并更新文档。
Installation
npm install @8area8/domstrict --save
Usage
Javascript
var get = require("@8area8/domstrict");
var $element = get.id("foo");
- Returns an HTMLElement OR throws an Error.
TypeScript
import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
- Returns an Array<Element> OR throws an Error.
API
class Get {
static id(idName: string): HTMLElement;
static class(idName: string): Element[];
static query(selector: string): Element;
static queryAll(selector: string): Element[];
}
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]
Test
npm run test
domstrict
wrapper for the "getElement" and "querySelector" methods. Return the element or an error.
News
Add the $base
parameter for query and queryAll. Todo: Create tests and update the documentation.
Installation
npm install @8area8/domstrict --save
Usage
Javascript
var get = require("@8area8/domstrict");
var $element = get.id("foo");
- Returns an HTMLElement OR throws an Error.
TypeScript
import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
- Returns an Array<Element> OR throws an Error.
API
class Get {
static id(idName: string): HTMLElement;
static class(idName: string): Element[];
static query(selector: string): Element;
static queryAll(selector: string): Element[];
}
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]
Test
npm run test