Current location - Quotes Website - Personality signature - How does jquery get the id of the dynamically increasing img tag?
How does jquery get the id of the dynamically increasing img tag?

1. Create a new html file and name it test.html.

2. in the test.html file, within the p tag, use the span tag to create a line of text, which is the child tag of the p tag.

3. in the test.html file, set the id of the span element as myspan, which will be obtained by jquery method.

4. in the test.html file, use the button tag to create a button named "get the ID value of the child tag".

5. in the test.html file, bind the onclick click event to the button, and execute the getspanid function when the button is clicked.

6. in the js tag, create the getspanid () function. within the function, get the p element object through the element name, use the children () method to get the child tag of the p tag, and then get the id value through the attr () method. Finally, use the alert () method to output the id value. ?