How can I pass a parameter to a setTimeout() callback?

前端 未结 28 1948
既然无缘
既然无缘 2020-11-21 07:31

I have some JavaScript code that looks like:

function statechangedPostQuestion()
{
  //alert("statechangedPostQuestion");
  if (xmlhttp.readyState==         


        
28条回答
  •  别跟我提以往
    2020-11-21 08:18

    this works in all browsers (IE is an oddball)

    setTimeout( (function(x) {
    return function() {
            postinsql(x);
        };
    })(topicId) , 4000);
    

提交回复
热议问题