You can use Bracket notation to access the property of an object dynamically:
let t = "val";
$('.class')[t]();
This will call the method with the name that matches the value of the t variable on the jQuery object with the class. If the method exists on the object, it will be called with the appropriate arguments.
2
Answers
you want this slove?
You can use Bracket notation to access the property of an object dynamically:
This will call the method with the name that matches the value of the t variable on the jQuery object with the class. If the method exists on the object, it will be called with the appropriate arguments.