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

JavaScript से दस्तावेज़ में पहली इमेज की ID कैसे लौटाएं?


पहली इमेज की ID लौटाने के लिए, JavaScript में images प्रॉपर्टी उपयोग करें।

उदाहरण

दस्तावेज़ में पहली इमेज की ID लौटाने के लिए निम्न कोड चलाएं:

<!DOCTYPE html> <html>    <body>       <img id="image1" src="https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg">       <img id="image2" src="https://www.tutorialspoint.com/hive/images/hive-mini-logo.jpg">       <img id="image3" src="https://www.tutorialspoint.com/sas/images/sas-mini-logo.jpg">       <img id="image4" src="https://www.tutorialspoint.com/maven/images/maven-mini-logo.jpg">       <script>          var val = document.images.length;          document.write("<br>Number of images in the document: "+val);          document.write("<br>The id of the first image: "+document.images[0].id);       </script>    </body> </html>

  1. - JavaScript से इमेज की चमक और कंट्रास्ट कैसे सेट करें?

    उदाहरण CSS filter प्रॉपर्टी से brightness() और contrast() फंक्शन का उपयोग करें। <!DOCTYPE html> <html> <body> <p>इमेज की चमक और कंट्रास्ट बदलने के लिए नीचे क्लिक करें।</p> <button onclick=display()>इमेज संपादित करें</button><br><br>

  1. - JavaScript से लिस्ट-आइटम मार्कर के रूप में इमेज कैसे सेट करें?

    उदाहरण listStyleImage प्रॉपर्टी से कस्टम इमेज को लिस्ट मार्कर के रूप में उपयोग करें। <!DOCTYPE html> <html> <body> <ol id=myID> <li>एक</li> <li>दो</li> </ol> <button type=button onclick=display()>लिस्ट इमेज अपडेट क

  1. - JavaScript में डॉक्यूमेंट से जुड़ी कुकीज़ कैसे प्राप्त करें

    JavaScript ने किसी भी प्रकार की डॉक्यूमेंट जानकारी से निपटने के लिए document ऑब्जेक्ट प्रदान किया है। इस ऑब्जेक्ट ने विशेष डॉक्यूमेंट से जुड़ी कुकीज़ प्राप्त करने के लिए document.cookie प्रदान किया है। यह मेथड कोड की किसी अन्य लाइन को परेशान नहीं करेगा। सिंटैक्स cookie = document.cookie; उदाहरण निम