Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> HTML

HTML DOM इमेजेज कलेक्शन प्रॉपर्टी

परिचय

HTML DOM images कलेक्शन प्रॉपर्टी HTML दस्तावेज़ में सभी <img> एलिमेंट्स का कलेक्शन लौटाती है।

सिंटैक्स

document.images

प्रॉपर्टी

प्रॉपर्टीव्याख्या
lengthHTML दस्तावेज़ में <img> एलिमेंट्स की संख्या लौटाता है।

मेथड्स

मेथडव्याख्या
[index]कलेक्शन से निर्दिष्ट इंडेक्स का <img> एलिमेंट लौटाता है।
item(index)कलेक्शन से निर्दिष्ट इंडेक्स का <img> एलिमेंट लौटाता है।
namedItem(id)कलेक्शन से निर्दिष्ट ID का <img> एलिमेंट लौटाता है।

उदाहरण

पेज पर इमेजेज की संख्या गिनना:

<!DOCTYPE html>
<html>
<head>
<style>
  body { text-align: center; }
  .btn {
    background-color: lightblue;
    border: none;
    height: 2rem;
    border-radius: 50px;
    width: 60%;
    margin: 1rem auto;
    display: block;
  }
  .show { color: #db133a; font-size: 2rem; font-weight: bold; }
</style>
</head>
<body>
<h1>DOM इमेज ऑब्जेक्ट उदाहरण</h1>
<img src="https://www.tutorialspoint.com/spring/images/spring-mini-logo.jpg" alt="Learn Spring">
<img src="https://www.tutorialspoint.com/hibernate/images/hibernate-mini-logo.jpg" alt="Learn Hibernate">
<img src="https://www.tutorialspoint.com/sql/images/sql-mini-logo.jpg" alt="Learn SQL">
<img src="https://www.tutorialspoint.com/plsql/images/plsql-mini-logo.jpg" alt="Learn PL/SQL">
<button onclick="getCount()" class="btn">इमेजेज की संख्या गिनें</button>
<div class="show"></div>
<script>
  function getCount() {
    document.querySelector('.show').innerHTML = document.images.length;
  }
</script>
</body>
</html>

आउटपुट

"इमेजेज की संख्या गिनें" बटन पर क्लिक करने पर पेज पर मौजूद इमेजेज की कुल संख्या (4) प्रदर्शित होगी।

  1. HTML DOM Style columnRuleWidth प्रॉपर्टी HTML DOM Style columnRuleWidth प्रॉपर्टी

    HTML DOM columnRuleWidth प्रॉपर्टी का उपयोग कॉलम नियम की चौड़ाई को सेट या प्राप्त करने के लिए किया जाता है।सिंटैक्स निम्नलिखित है:columnRuleWidth प्रॉपर्टी सेट करना:object.style.columnRuleWidth = medium|thin|thick|length|initial|inheritउपरोक्त प्रॉपर्टी मान निम्नलिखित हैं:मानविवरणthinयह एक पतला नियम

  1. HTML DOM Style columnRuleStyle प्रॉपर्टी HTML DOM Style columnRuleStyle प्रॉपर्टी

    HTML DOM Style columnRuleStyle प्रॉपर्टी का उपयोग कॉलम नियम की शैली को परिभाषित या प्राप्त करने के लिए किया जाता है।सिंटैक्स निम्नलिखित है:columnRuleStyle प्रॉपर्टी सेट करना:object.style.columnRuleStyle = none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset| initial|inheritउपरोक्त प्रॉपर

  1. HTML DOM Style columnRuleColor प्रॉपर्टी HTML DOM Style columnRuleColor प्रॉपर्टी

    HTML DOM columnRuleColor प्रॉपर्टी का उपयोग कॉलम के बीच नियम के रंग को सेट या प्राप्त करने के लिए किया जाता है।सिंटैक्स निम्नलिखित है:columnRuleColor प्रॉपर्टी सेट करना:object.style.columnRuleColor = color|initial|inheritयहां, रंग नियम के रंग को निर्दिष्ट करता है। Initial मान को डिफ़ॉल्ट मान पर सेट