javascript - Problem with parameters passed in settimeout
三叔
三叔 2017-07-05 11:06:49
0
2
775
  

Use settimeout to write the expansion and contraction of the secondary menu. Pass a function with parameters in settimeout. I don’t know how to pass it. In the video, it is written like this: setTimeout("addHeight('" ul "')",10 ) but it’s not normal. What’s the reason?

三叔
三叔

reply all (2)
某草草
setTimeout(function () {addHeight(ul)},10);
    漂亮男人

    setTimeout The first parameter of this function can accept a function or a piece of code. If it is code, put it intoevalfor execution.

    The way you write here is the way you write a piece of code. Please check whether the quotation marks are written correctly in one-to-one correspondence. Or change to the following two writing methods and it should work normally

    setTimeout(function () { addHeight(ul) }, 10);
    setTimeout(addHeight, 10, ul)
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!