Skip to content

dlvdls18/DocJect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DocJect

DocJect

Convert HTML Element and Object

DocJect.object(document.createElement("input"));
/*
{
  tag: "input",
  content: [],
  attr: {}
}
*/

Installation

<script src="https://cdn.jsdelivr.net/gh/dlvdls18/DocJect@main/src/docject.js"></script>

Documentation

Methods

/*
 * Converts HTMLElement to Object
 * DocJect.object(HTMLElement);
 * Returns Object
 */
DocJect.object();

/*
 * Converts Object to HTMLElement
 * DocJect.element(Object);
 * Returns HTMLElement
 */
DocJect.element();

Keys

Name Value Description
tag String Tag name of the element
content Array Content of the element
attr Object Attributes of the element

Key pair attributes

attr = {
  color: "red"
}
// <... color="red"></...>

Content

Content array values can be Object and String.

content = [
  "Hello",
  {
    tag: "b",
    content: ["World"],
    attr: {}
  }
];
// <...>Hello<b>World</b></...>

About

Convert HTML Elements and Object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published