if (!json.count) {
                            var tmp = null;
                            $.each(json, function(i, item) {
                                $(o.ulProvince).append("<li id='" + item.id + "'  >" + unescape(item.name) + "</li>");
                                tmp = document.getElementById(item.id);
                                tmp.onclick = function() { o.getCity(event, this); }
                            });
                            hid.style.display = hid.style.display = "block";
                            o.divAreaContent.style.display = "block";
                        }getCity 这个函数中火狐里不执行。
但是我不要event这个参数他就能执行。。
这个怎样搞的?

解决方案 »

  1.   

    tmp.onclick = function() { o.getCity(event, this); }改成tmp.onclick = function(event) { o.getCity(event, this); }
      

  2.   


    tmp.onclick = function(event) { var event = event || window.event; o.getCity(event, this); }
      

  3.   

    谢谢回答。但是照样没有反应。。真是气死。。  tmp.onclick = function(event) { var event = event || window.event; o.getCity(event, this); }
      

  4.   

    tmp.onclick = function(e) { e =  window.event||e; o.getCity(e, this); }
      

  5.   

    2楼那样,下面的var,把event覆盖了
      

  6.   


       $.each(json, function(i, item) {
                                    $(ulCity).append("<span id='" + item.id + "' class='leftinline' onmouseout='this.style.backgroundColor = \"#feffef\";' onmouseover='this.style.backgroundColor = \"#ffa22e\";' >" + unescape(item.name) + "</span>");
                                    itm = document.getElementById(item.id);
                                    itm.onclick = function() { o.cityLiClick(this); }
                                });这句子火狐里就怎么错了呢?
     $(ulCity).append("<span id='" + item.id + "' class='leftinline' onmouseout='this.style.backgroundColor = \"#feffef\";' onmouseover='this.style.backgroundColor = \"#ffa22e\";' >" + unescape(item.name) + "</span>");
      

  7.   


    $(ulCity).append(" <span id='" + item.id + "' class='leftinline' onmouseout='this.style.backgroundColor = \"#feffef\";'就直接这句。。
    恩。
      

  8.   

    用jq就用这么多id了吧?之前不是说了可以用appendTo$("<span>test</span>").appendTo(document.body).click(function(){
    alert("just test");
    });上面的啥意思?
      

  9.   

    我是将 span 插入到 ul 元素的
      

  10.   

    o.cityLiClick(this); 这个需要什么参数?
      

  11.   

    插入到什么中是一样的,appendTo会返回前面的元素,后面就可以直接操作
      

  12.   

    什么参数都不要。。  $.each(json, function(i, item) {                                
    $(ulCity).append("<span class='leftinline'  >" + unescape(item.name) + "</span>");
     }
        alert("2");
     });我这样他照样不执行的。
    我说下我的结构。。
    首先是省的ul 点击 省之后 就出现 市的 ul ,他们的结构都是<div><ul></ul></div>. <div id="divAreaContent" style="display: none;" class="dragDiv">
            <div id="dragDivHeader" class="dragDivHeader">
                <ul id="ulSelectResult">
                </ul>
                <span id="closespan2" style="float: right; margin-right: 20px; cursor: pointer;">关闭</span>
            </div>
            <br />
            <div id="divProvince" class="divProvince">
                <ul id="ulProvince">
                </ul>
            </div>
        </div>
        <div id="cityArea" style="display: none; z-index: 5000;">
            <ul id="ulCity">
            </ul>
        </div>
      

  13.   

    $.each(json, function(i, item) {                                
    $(o.ulCity).append("<span class='leftinline'  >" + unescape(item.name) + "</span>");
     }
        alert("2");
     });o.ulCity 少了一个o
      

  14.   

    呵呵。。谢谢sky。那么晚还不睡?你整天在写程序。
    一天在csdn?