[removed] get a function's variable's value within another function

前端 未结 5 1464
故里飘歌
故里飘歌 2020-12-08 21:20

okay so I have this code in body:


And this code in script

<         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 22:07

    you need a return statement in your first function.

    function first(){
        var nameContent = document.getElementById('full_name').value;
        return nameContent;
    }
    

    and then in your second function can be:

    function second(){
        alert(first());
    }
    

提交回复
热议问题