function editar(clicked_id){
var currentID = clicked_id;
alert(clicked_id);
}
我想将var currentID
传递给getElementById
var tituloAgain = document.getElementById(clicked_id).value;
console.log(tituloAgain);
答案 0 :(得分:0)
您可以将currentID的定义移到函数外部,使其成为全局变量。然后你可以在函数内部给它一个值,如下所示:
var currentID;
function editar(clicked_id){
currentID = clicked_id;
alert(clicked_id);
}
var tituloAgain = document.getElementById(currentID).value;
console.log(tituloAgain);