에서 다음 jQuery
과 같이 변수에 노드를 저장할 수 있습니다. variable = $(.element)
그런 다음 해당 변수를 통해 노드를 조작합니다.variable.hide()
ES6에서 이것을 할 수 있습니까? 다음과 같이 표시됩니다.
var variable = document.querySelector('.portfolio').style.display = 'block'
variable.style.display = 'none'
이것이 작동하지 않는 것을 제외하고.
한 줄의 코드에서 두 가지 다른 작업을 수행하려고합니다. 먼저 요소를 변수에 할당 한 다음 변수를 사용하여 스타일을 수정할 수 있습니다. 아래 코드 조각을 참조하십시오.
// First assign the element to a variable
var myElement = document.getElementById('myElement');
// Then use the variable to modify the elements style
myElement.style['background-color']='red';
<div id="myElement">element</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다