Skip to content

Commit d42b0f9

Browse files
committed
added functions to control element's id
1 parent 3e1cc0a commit d42b0f9

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,17 @@ loading will not work properly. Especially when changing from linear to circular
296296

297297
When removing main class from element, it will no longer be visible, but it will still be present in the DOM!
298298

299+
### ID control
300+
301+
To set, change or remove element's ID use these functions:
302+
303+
```javascript
304+
// sets or changes id of the element (don't forget, id has to be unique)
305+
element.setId("new_id");
306+
// removes id from the element
307+
element.removeId();
308+
```
309+
299310
### Label control
300311

301312
There are provided functions to change or remove labels with JavaScript. They are called on the element object as well as

dist/main.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ declare namespace lv {
4747
removeLabel(): void;
4848
showPercentage(): void;
4949
hidePercentage(): void;
50+
setId(idText: string): void;
51+
removeId(): void;
5052
/**
5153
* adds class or classes to element
5254
* @param classString - string that contains classes separated with one space

dist/main.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loading-visualization",
3-
"version": "1.2.9",
3+
"version": "1.2.10",
44
"description": "CSS and JavaScript library for determinate and indeterminate loading bars and spinners",
55
"license": "BSD-3-Clause",
66
"author": "Jakub Rada",

src/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ namespace lv {
150150
this.element.removeAttribute("data-percentage");
151151
}
152152

153+
public setId(idText: string): void {
154+
this.element.setAttribute("id", idText);
155+
}
156+
157+
public removeId(): void {
158+
this.element.removeAttribute("id");
159+
}
160+
153161
/**
154162
* adds class or classes to element
155163
* @param classString - string that contains classes separated with one space

0 commit comments

Comments
 (0)