简体   繁体   English

jQuery〜函数,仅与警报一起使用

[英]Jquery ~ Function, just working with alert

I have the following function that is actually working on Chrome and Firefox, but its´not working in Internet Explorer 我具有实际上在Chrome和Firefox上可以使用的以下功能,但是在Internet Explorer中无法使用

$(".info").on("click", function(e){
        //alert("Message");
        if(tp==0){
            fila[0]=$(this).children();
            fila[1]=$(this).children().slice(0,2);
            var x = $(this).children().children().children().attr('title');

            var tot="<td colspan='7' style='font-size:22px;'>"+x+"</td>";
            $(this).html(fila[1][0]);
            $(this).append(fila[1][1]);
            $(this).append("<td colspan='7' style='font-size:22px;'>"+x+"</td>");
        }
        tp=1;
    });

I make it works on IE if the alert line is uncommented like this: 如果警报行没有注释,我可以使它在IE上运行:

$(".info").on("click", function(e){
        alert("Message");
        if(tp==0){
            fila[0]=$(this);
            fila[1]=$(this).slice(0,2);
            var x = $(this).attr('title');

            var tot="<td colspan='7' style='font-size:22px;'>"+x+"</td>";
            $(this).html(fila[1][0]);
            $(this).append(fila[1][1]);
            $(this).append("<td colspan='7' style='font-size:22px;'>"+x+"</td>");
        }
        tp=1;
    });

The question is, how can I make it works without this alert on IE? 问题是,如何使它在IE上没有此警报的情况下起作用? Sorry for my bad English. 对不起,我的英语不好。

For those that ask me, here is where I def my "tp" 对于那些问我的人,这里是我定义我的“ tp”的地方

<script type="text/javascript">
     var pedidos_carritos = [];
     var linea = [];
     var cont;
     var aux=0;
     var tp=0;
     var fila =[];

Just put console.log("your message") instead of an alert and check if it works. 只需放置console.log(“您的消息”)而不是警报,然后检查它是否有效。 I am not sure. 我不确定。

Until you can fix this in IE, you need to know which line of code isn't working. 在IE中解决此问题之前,您需要知道哪一行代码不起作用。 You've only put your alert in one place. 您只将警报放在一个地方。 Try putting it AFTER the if statement and then try every line after that until you can pinpoint it down. 尝试将其放在if语句之后,然后尝试之后的每一行,直到可以将其精确定位为止。

You could also step through in the debugger, but above will be easier if you have never done this. 您也可以逐步进入调试器,但是如果您从未这样做过,则上面的操作会更容易。

Is this code at the bottom of the page / in a document ready function? 此代码是否在页面底部/文档就绪功能中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM