In order to perform different operations on different elements in javascript, it is necessary to judge the elements that trigger the event in javascript and then perform different operations.
example:
html
<input type='button' name='updatemetal' value='modify' onclick='getmetalid(this)'>
<input type='button' name='deletemetal' value='delete' onclick='getmetalid(this)'>
javascript
<script type="text/javascript">
function getmetalid(input) {
metalid = ;
if(("value") == 'Modify'){
damicsubmit(metalid);
}else if(("value") == 'delete'){
damicsubmit2(metalid);
}
}
</script>
It was not successful to obtain the name and id attributes of the input, but the value is OK. I don't know why.
refer to:
var obj=("div1").getElementsByTagName("textarea")
for(var i=0;i<;i++)
{
if(obj[i].id=="aa")
{
alert(obj[i].innerText)
}
}
example:
html
Copy the codeThe code is as follows:
<input type='button' name='updatemetal' value='modify' onclick='getmetalid(this)'>
<input type='button' name='deletemetal' value='delete' onclick='getmetalid(this)'>
javascript
Copy the codeThe code is as follows:
<script type="text/javascript">
function getmetalid(input) {
metalid = ;
if(("value") == 'Modify'){
damicsubmit(metalid);
}else if(("value") == 'delete'){
damicsubmit2(metalid);
}
}
</script>
It was not successful to obtain the name and id attributes of the input, but the value is OK. I don't know why.
refer to:
Copy the codeThe code is as follows:
var obj=("div1").getElementsByTagName("textarea")
for(var i=0;i<;i++)
{
if(obj[i].id=="aa")
{
alert(obj[i].innerText)
}
}