Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
/ sQuery Public archive

sQuery - a mini library for selecting DOM elements

License

Notifications You must be signed in to change notification settings

pvzzombs/sQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 

Repository files navigation

sQuery

CodeFactor HitCount
sQuery - a mini library for selecting DOM elements
Note "sQuery" is just my remake of famous DOM selector ...
Stable version: 1.5 + fix - sQuery.js
Minified: 1.5 + fix - sQuery.min.js  

Usage


Step 1 Include the `sQuery.js` file in your html head tag.
<head>
  <script src="sQuery.js"></script>
</head>

Step 2 Run the sQuery file after the documents or window loads. You can give it a name of your own. Like creating a new function constructor.
// sQuery v1.0

function $(e){
    return new sQuery(e);
}
window.onload = function(){
    $("p").text("Hello");
};

// NOW sQuery v 1.1.1 and above now supports .ready() method

sQuery("document").ready(function(){
  //code here
});

List of properties and methods

.ready(function()...)

executes a function once the DOM was ready
best use with document

.call(function(element)...)

accepts a function and then executes the function for the element selected.
the function must contain also a param that would accept the elements to come.

.html(string)

accepts a string
changes the innerHTML of element to the specified string
returns the html of the selected element if param is empty

.text(string)

accepts a string
changes the innerText of element to the specified string

.value(string)

accepts a string
changes the value of element to the specified string

.color(string)

changes the color of the element to the specified string

.on("event",function()...)

adds an event to the corresponding function
returns false to prevent popping, bubbling etc...

.toggle()

toggles the current display of the element to either none or block

.txt()

returns the innerText of the selected element

.val()

returns the value of the selected element

.css(property,value)

changes the assign style property to the element with the given value

About

sQuery - a mini library for selecting DOM elements

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published