function $(def){
	try{
		if(def.charAt(0) == "#"){
			return document.getElementById(def.replace("#",""))
		}else if(def.charAt(0) == "."){
			return document.getElementsByClassName(def.replace(".",""))
		}else if(def.charAt(0) == "@"){
			return document.getElementsByTagName(def.replace("@",""))
		}else if(def.charAt(0) != "#" && def.charAt(0) != "."){
			console.error("bad define with >>> " + def)
		}
	}catch(err){
		console.error(err)
	}
}
HTMLElement.prototype.text = function(str){
	this.innerHTML = str
}
HTMLElement.prototype.click= function(eve){
	this.addEventListener("click",function(){
		setTimeout(eve,0)
	})
}
function keyevent(key,eve){
	try{
	if(key.charAt(0) == "@"){
		window.addEventListener("keydown",function(){
			if(event.code == key.replace("@","")){
				setTimeout(eve,0)
			}
		})
	}else if(key.charAt(0) == "#"){
		window.addEventListener("keyup",function(){
			if(event.code == key.replace("#","")){
				setTimeout(eve,0)
			}
		})
	}else if(key.charAt(0) == "."){
		window.addEventListener("keypress",function(){
			if(event.code == key.replace(".","")){
				setTimeout(eve,0)
			}
		})
	}
	}catch(err){
		console.error(err)
	}
}

Open in new window

i made something like jquery
the using like almost like jquery
$("") for define the Elements use the dot for classes and # for id and @ for tags
and click method to make click event Ex.. > element.click(function(){//code here})
and text() like jquery edit the innerHTML value
keyevent to do event with press key and upkey and downkey
use the @ for keydown
use the # for keyup
use the . for keypress
and more coming

who can help me to add cool ideas

0

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month