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

JavaScript dynamically determines html elements and performs different operations_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:44:26900browse

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)
}
}
Statement:
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