Files
ClassContent/历届学生/front-end-team-11/项目开发/学生项目/贡婉宝/水管鸟/js/clas.js
2024-09-27 02:06:13 +08:00

33 lines
885 B
JavaScript

class incommon{
$(name){
return document.querySelector(name);
}
_(name){
return document.querySelectorAll(name);
}
customMethods(){
Element.prototype.add=function(name){
this.classList.add(name)
}
Element.prototype.remove=function(name){
this.classList.remove(name)
}
Element.prototype.none = function() {
this.style.display = "none"
}
Element.prototype.show = function() {
this.style.display = "block"
}
}
getRandom(min, max) {
const floatRandom = Math.random()
const difference = max - min
const random = Math.round(difference * floatRandom)
const randomWithinRange = random + min
return randomWithinRange
}
}
let { $, _ ,customMethods,getRandom} = new incommon()
customMethods()