我想知道究竟是什么之间的差异querySelector和querySelectorAll对抗 getElementsByClassName和getElementById?
从这个链接我可以收集,querySelector我可以编写document.querySelector(".myclass")获取类的元素,myclass并document.querySelector("#myid")获取ID元素myid.但我已经可以做到这一点getElementsByClassName和getElementById.应该首选哪一个?
我也在XPage中工作,其中ID是用冒号动态生成的,看起来像这样view:_id1:inputText1.所以当我写document.querySelector("#view:_id1:inputText1")它不起作用.但写作document.getElementById("view:_id1:inputText1")有效.有什么想法吗?
如何更改CSS的伪元素样式?
我正在尝试获取CSS before::规则并将其更改left:为95%或4px。如何在我的上下文中执行此操作?
我也使用进行了一些测试,document.querySelector但是它不起作用,出现了计算只读错误。
有什么建议吗?
例:
.iziToast-wrapper-bottomLeft .iziToast.iziToast-balloon:before {
border-right: 15px solid transparent;
border-left: 0 solid transparent;
right: auto;
left: 8px;
}
Run Code Online (Sandbox Code Playgroud)
if(description_iziToast){
let RightMode = event.x>window.innerWidth/2;
let bubblePosition = document.getElementsByClassName("iziToast-balloon")[0]; // get the div that hold the bubble
let ajustScreenLR = RightMode && document.getElementsByClassName("iziToast")[0].offsetWidth || 0; // halfScreen ajustement
//bubblePosition.style.left = RightMode && '95%' || '4px'; // here i need to change the position in the befor:: attribut …Run Code Online (Sandbox Code Playgroud)