Is there any way to select current tag as DOM element without using id attribute?
What I'm currently doing is;
function addAttr(n,v){
var ta = document.getElementById(opts.id);
ta.setAttribute(n,v);
}
I'm looking for some direct way like this;
function addAttr(n,v){
var ta = document.querySelector(this);
//var ta = document.querySelector(this.root);
ta.setAttribute(n,v);
}
Passing this.root
works with jQuery but not with document.querySelector()
I got the solution. I moved my code in 'mount' event. So
this.root
is available. Now I don't need query selector. this.root works in itself.Now I can directly use;
I have updated plunker link for reference.