Giter Club home page Giter Club logo

stardom's Introduction

starDOM

A lightweight DOM manipulation library that includes AJAX requests and event handling.

Frontpage

starDOM Live

Javascript Objects

starDOM's $s can be passed an HTML element or a CSS selector to create a Javascript object with increased functionality.

  let $newElement = $s("<section/>")

When passed a function, starDOM will invoke said function when the DOM is fully loaded.

  $s(() => console.log("To infinity... and beyond!"));

Public API

html

Get and Set innerHTML.

//get
  $newElement.html()

//set
  $newElement.html("To infinity... and beyond!")

append

Add child elements.

  $newElement.append(children)

addClass

Add a CSS class.

  $newElement.addClass(className)

removeClass

Remove CSS class.

  $newElement.removeClass(className)

attr

Get and Set attributes.

//get
  $newElement.attr(attrName)

//set
  $newElement.attr(attrName, value)

children

Get children.

  $newElement.children()

parent

Get parent.

  $newElement.parent()

find

Find by selector.

  $newElement.find(selector)

empty

Clear innerHTML.

  $newElement.empty()

off

Remove event listener.

  $newElement.off("eventName", callback)

on

Add event listener.

  $newElement.on("eventName", callback)

remove

Remove from DOM.

  $newElement.remove()

AJAX

starDOM uses XMLHttpRequests for it's ajax method.

  $s.ajax({
      method: "GET",
      url: "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_key=DEMO_KEY",

      success: function (data) {
        console.log("To infinity... and beyond!");
      },
      error: function (data) {
        console.log("I'm sorry Dave.  I'm affraid I can't do that.");
      }
  });

stardom's People

Contributors

pts9789 avatar

Stargazers

Sandy Mak avatar David Veytsman avatar Benny Zhao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.