Skip to content

Commit f3dec82

Browse files
committed
Version 1.3
1 parent 3a1410c commit f3dec82

1 file changed

Lines changed: 63 additions & 13 deletions

File tree

README.md

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ GStime is a lightweight, feature-rich, and easy-to-use JavaScript library design
1212
- **Easy to use**: Straightforward for those familiar with jQuery or vanilla JavaScript.
1313
- **Chainable Methods**: Perform multiple methods on the same line of code with returned `this` for most methods.
1414
- **Server-side compatibility**: Checks for the existence of `document` to support usage in server-side environments.
15+
- **Multiple Element Support**: Most methods operate on and return collections of elements, not just single elements.
16+
17+
## Chainable Methods
18+
19+
Many methods in GStime return the GStime object, allowing for method chaining. This includes methods like `addClass()`, `removeClass()`, `append()`, `prepend()`, `hide()`, `show()`, and more. For example:
20+
21+
```javascript
22+
$('.element')
23+
.addClass('new-class')
24+
.css('color', 'red')
25+
.show()
26+
.append('<p>New content</p>');
27+
```
28+
29+
## Multiple Element Support
30+
GStime supports operating on multiple elements at once. When you select elements using $(), it returns a GStime object containing all matched elements. Methods like each(), addClass(), removeClass(), etc., operate on all selected elements.
1531

1632
## How to Use
1733

@@ -20,21 +36,30 @@ Include GStime in your project:
2036
```html
2137
<script src="path-to-GStime.js"></script>
2238
<script>
23-
// DOM Ready
24-
GStime.ready(function() {
25-
// Click event
26-
$('.element').on('click', function() {
27-
console.log('Element clicked!');
28-
});
29-
30-
// Changing value
31-
$('.input').val('New Value');
32-
33-
// Adding HTML content
34-
$('.container').append('<p>New paragraph</p>');
39+
// DOM Ready
40+
GStime.ready(function () {
41+
// Click event
42+
$(".element").on("click", function () {
43+
console.log("Element clicked!");
3544
});
45+
46+
// Changing value
47+
$(".input").val("New Value");
48+
49+
// Adding HTML content
50+
$(".container").append("<p>New paragraph</p>");
51+
});
52+
53+
GStime.ajax({
54+
url: "https://api.example.com/data",
55+
method: "GET",
56+
success: function (response) {
57+
console.log("Data received:", response);
58+
},
59+
});
3660
</script>
3761
```
62+
3863
## Methods Available
3964

4065
### Element Selection and Manipulation
@@ -44,6 +69,17 @@ Include GStime in your project:
4469
- `html([content])`: Get/set the HTML content of elements.
4570
- `append(content)`: Append content to elements.
4671
- `prepend(content)`: Prepend content to elements.
72+
- `after(content)`: Insert content after each element.
73+
- `before(content)`: Insert content before each element.
74+
- `remove()`: Remove the set of matched elements from the DOM.
75+
76+
### DOM Traversing
77+
78+
- `parent()`: Gets the parent of each element.
79+
- `children()`: Gets the children of each element.
80+
- `siblings()`: Gets the siblings of each element.
81+
- `find(selector)`: Finds descendants of each element.
82+
- `closest(selector)`: Gets the first ancestor that matches the selector.
4783

4884
### CSS Properties
4985

@@ -89,6 +125,8 @@ Include GStime in your project:
89125

90126
- `clone()`: Create a shallow copy of elements.
91127
- `each(callback)`: Iterate over elements.
128+
- `each(obj, callback)`: Iterate over an array or object.
129+
- `map(obj, callback)`: Translate all items in an array or object.
92130

93131
### Static Methods
94132

@@ -101,4 +139,16 @@ Contributions, issues, and feature requests are welcome! Feel free to check the
101139

102140
### License
103141

104-
This project is MIT licensed.
142+
This project is MIT licensed.
143+
144+
## Browser and Environment Support
145+
GStime is designed to work in modern browsers that support ES6 features. It should work in:
146+
147+
Chrome 51+
148+
Firefox 54+
149+
Safari 10+
150+
Edge 15+
151+
Opera 38+
152+
For server-side environments, GStime is compatible with Node.js 6.4.0 and later versions.
153+
154+
Note: Some features may require additional polyfills for older browsers. For the best experience and widest compatibility, consider using GStime with a modern browser or environment.

0 commit comments

Comments
 (0)