document.querySelectorAll(':not(th)')
document.querySelectorAll('#fileList tbody tr:not(.sampleRow, #noFile)')
document.querySelector('#encodingForm select[name="encStatus"]').value
$('#form').find('select[name="name"]').val();
table.querySelectorAll('input[type="radio"]:checked')
let originString = target.querySelector('[class="t1"]').textContent;
trElem.querySelector('button.tree-file')
this.#target.querySelector('input[data-all-check]')
el.classList.replace('show', 'hide')
tbody?.querySelectorAll('tr').forEach((item) => {
if (item.classList.contains('no-data')) {
while (tbody.firstChild) {
tbody.removeChild(tbody.firstChild);
}
}
})
var element = document.querySelector('.some-selector');
element.classList.add('new-class-name');
copyRow.classList.remove('sampleRow')
const table = obj.contentWindow.document.getElementById("list-d1");
authTable = e.contentWindow.document.getElementById('list') ||
e.contentDocument.getElementById('ist');
[data=keyword]
: 속성 data
의 값이 정확히 keyword
와 일치하는 요소 찾기
[data^=keyword]
: 속성 data
의 값이 keyword
로 시작하는 요소 찾기
[data$=keyword]
: 속성 data
의 값이 keyword
로 끝나는 요소 찾기
[data*=keyword]
: 속성 data
의 값이 keyword
가 포함되는 요소 찾기
const newObject = window.parent?.document?.querySelector("[data*=" + modal + "]")
const footBtns = newObject.contentDocument.querySelectorAll('.modal-pop-foot button');
const boxDocument = window.parent?.document?.querySelector("[data*='/rfidLabel']");
window.top.location.reload();
const sidePop = window.parent?.document?.querySelector('.side-pop');
window.parent.document.location.href = CONTEXT_PATH;
window.parent.document.querySelector('#body_content');
let fileUrl = window.URL.createObjectURL(result);
const allObjectTag = parent.document.querySelectorAll('object');
let authTable = null;
allObjectTag.forEach((e) => {
let style = e.getAttribute('style');
let className = e.getAttribute('class');
if ((style === null || style.indexOf('z-index') === -1) &&
(className === null || className.indexOf('on') === -1)) {
authTable = e.contentWindow.document.getElementById('list') ||
e.contentDocument.getElementById('list');
}
});
nextElem.hasAttribute('data-parent-code');
target.setAttribute('data-parent-code', parentCode);
getElementById
의 단점document
요소에서만 사용가능함 -> querySelector
를 사용하는 이유
let interval = setInterval(() => {
if (e.querySelector('#hiddenArr')) {
clearInterval(interval); // 폴링 중지
const item = e.querySelector('#hiddenArr').querySelector('input');
bldgArr = JSON.parse(item.value)
console.log(bldgArr)
} else {
console.log('대기중');
}
}, 10);
apendChild
는 노드만 추가 가능합니다.
예를 들어 parentElement.appendChild(childNode);
처럼 element
를 추가할 때 사용합니다.
반면에 append
는 노드와 텍스트를 추가할 때 사용합니다.
parentElement.append(childNode, textNode, 'text')
자식 변화 감지
// 사이드뷰가 닫히면 실행시킬 함수
const targetNode = parent.document?.querySelector("[data*='/detail']")
const observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
// Object 태그가 DOM에서 사라졌는지 확인
if (!parent.document.contains(targetNode)) {
searchRtFnc();
observer.disconnect();
break;
}
}
}
});
observer.observe(parent.document, { childList: true, subtree: true }); // 자식 노드 관찰, 하위 노드 관찰
속성 변화 감지
const observer2 = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
// 자신의 속성 변화 감지
if (mutation.type === 'attributes') {
if (mutation.attributeName === 'style') {
}
}
}
});
observer2.observe(target, { attributes: true });