Home > Web Front-end > JS Tutorial > JavaScript dynamically determines html elements and performs different operations_javascript skills

JavaScript dynamically determines html elements and performs different operations_javascript skills

WBOY
Release: 2016-05-16 16:44:26
Original
930 people have browsed it

In order to perform different operations on different elements in JavaScript, you need to judge the element that triggers the event in JavaScript, and then perform different operations.

Example:

html

Copy code The code is as follows:




javascript
Copy code The code is as follows :



Acquisition of the name and id attributes of the input is unsuccessful, but the value is OK. I don’t know why. What reason.

Reference:
Copy code The code is as follows:

var obj=document .getElementById("div1").getElementsByTagName("textarea")
for(var i=0;i{
if(obj[i].id==" aa")
{
alert(obj[i].innerText)
}
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template