Qus : Which method is used to find an HTML element by its ID?
Qusकिसी HTML तत्व को उसकी आईडी द्वारा खोजने के लिए किस विधि का उपयोग किया जाता है?
A. getElementByTagName() B. getElementById()
C. getElementByClass() D. querySelector()
Solution
B. getElementById()
Explanation
The getElementById() method is the most commonly used method to access an HTML element by its unique id attribute. It returns a single element that matches the given ID.