Home  >  Q&A  >  body text

How to use methods in variables

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>ajax</title>

</head>

<body>

<button onclick="ass.ss() ">Execute</button>

<script>

var ass = function ss() { alert("hello") };

//Solve How can I execute the ss() method

</script>

</body>

</html>

奇遇奇遇1964 days ago1029

reply all(1)I'll reply

  • angryTom

    angryTom2019-07-15 11:46:22

    Just use the variable name plus parentheses to access it. You can use ass() directly

    reply
    0
  • Cancelreply