I am trying to add a attribute (dynamically created) to a div. But it is not working here.
var style3=createElement('style');
style3.type="text/css";
var target3=document.getElementById('target3');
target3.addEventListener('click',function(){
style3.innerHTML='.target4{background-color:#444;}';
document.getElementsByTagName('head')[0].appendChild(style3);
target3.setAttribute('class','target4');
});
Also, is it possible to set pseudo elements dynamically to that div?.