JavaScript QuerySelector - dengan atribut

<p title="1st item with title">Paragraph with 1st title.</p>
<p title="2nd item with title">Paragraph with 2nd title.</p>
<button onclick="getElement()">Get element with title attribute</button>

<script>
  function getElement() {
    let element = document.querySelector("[title]");
    element.style.background = "lightgreen";
  }
</script>
Clumsy Caiman