I want to create link that send to function:
JavaScript
x
3
1
tdLink2.innerText="Delete";
2
tdLink2.href="javascript:deleteDepartment(id)"
3
but the “id” parameter was not sent. How can I insert the parameter?
Advertisement
Answer
If id
is already a defined variable then you can do like this:
JavaScript
1
2
1
tdLink2.href=`javascript:deleteDepartment(${id})`
2
You can do this if it is of type string.
Otherwise you can go for this:
JavaScript
1
5
1
function f(){
2
deleteDepartment(id)
3
}
4
tdLink2.href='javascript:f()'
5