How do you spell it in the element's attribute?



  • It is necessary that the value of the "nomer" of the selected list element be recorded in the current number of the div blade. Give me your coat!

    <html>
      <head>Вывод содержимого элемента списка</head>
      <body>
        <div текущий номер=""> 
          <ul>
            <li номер="1">Первый</li>
            <li номер="2">Второй</li>
          </ul>
        </div> 
        <script type="text/javascript">
          var li_elements = document.getElementsByTagName('li');
            for (i = 0; i < li_elements.length; i++) {
              li_elements[i].onclick = function () {
                alert("номер элемента: " + this.getAttribute("номер"));
                document.body.div.setAttribute('текущий номер', 'this.getAttribute("номер")');
                }
              }
          </script>
      </body>   
    </html>
    


  • el.setAttribute("номер", "1")
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2