在 javascript 中将鼠标悬停事件从一个函数发送到另一个函数

send a mouse over event from one function to another function in javascript

我想获取字体标签的id,然后将其传递给changeText函数,这样我就可以显示

中的文字
<font id='1' onmousedown="getID(this)" onmouseup="changeText()"> hello </font>
<script type="text/javascript">

    function getID(el) {   
        var wordID = $(el).attr("id");
        console.log('getID ',wordID);
        return wordID;

    }

    var info = getID()

    words = {'1':'привет','2':'моё','3':'имя','4':'являться','5':'мэтт'}

    function changeText() {
        var display = document.getElementById(info);
        display.innerHTML = '';
        display.innerHTML = words['1'];
    }
  

</script>

您可以将它合并到一个函数中,不需要两个函数,因为 getID 只是获取一个变量..

function changeText(){
    var wordID = $(el).attr("id");
    var display = document.getElementById(info);
    display.innerHTML = '';
    display.innerHTML = words['1'];

}