Home >Web Front-end >JS Tutorial >How to use item method in javascript
How to use the item method in JavaScript: First create an html file named item; then add a button button, and add the custom function myitem to the click event; finally use the item method to obtain the corresponding node object and node name.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
Create an html file named item
Add a button button and add a custom function to the click event myitem
Add a p tag and set the id to showitem
Create a custom function myitem
Get the p element object in the custom function, and use the item method to get the node object and node name whose index is 1 in the body's own point.
In the browser Open the file and click the button to see the effect
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to use item method in javascript. For more information, please follow other related articles on the PHP Chinese website!