You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-13Lines changed: 63 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,22 @@ GStime is a lightweight, feature-rich, and easy-to-use JavaScript library design
12
12
-**Easy to use**: Straightforward for those familiar with jQuery or vanilla JavaScript.
13
13
-**Chainable Methods**: Perform multiple methods on the same line of code with returned `this` for most methods.
14
14
-**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.
15
31
16
32
## How to Use
17
33
@@ -20,21 +36,30 @@ Include GStime in your project:
20
36
```html
21
37
<scriptsrc="path-to-GStime.js"></script>
22
38
<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!");
35
44
});
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
+
});
36
60
</script>
37
61
```
62
+
38
63
## Methods Available
39
64
40
65
### Element Selection and Manipulation
@@ -44,6 +69,17 @@ Include GStime in your project:
44
69
-`html([content])`: Get/set the HTML content of elements.
45
70
-`append(content)`: Append content to elements.
46
71
-`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.
47
83
48
84
### CSS Properties
49
85
@@ -89,6 +125,8 @@ Include GStime in your project:
89
125
90
126
-`clone()`: Create a shallow copy of elements.
91
127
-`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.
92
130
93
131
### Static Methods
94
132
@@ -101,4 +139,16 @@ Contributions, issues, and feature requests are welcome! Feel free to check the
101
139
102
140
### License
103
141
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