why is my JS is working only when I debug?

1952 views javascript
6

I'm trying to change my #indexImg content through JS but it works only when I step through the code.

$(document).ready(function(){ 
  $("#content1Tab, #content2Tab").click(function(event) {          
        var myString = $(this).attr('id');
        var parts = myString.split("Tab");
        var thePart = parts[0];
        $("#container").load("../index.php #container> *", function() {                
            $('#btnOpen').click(function(){ 
                $("#container").load("../page.php #containerOther> *");
            });
        });
        $("#content1Tab, #content2Tab").css('z-index', 7);
        $(this).css('z-index', 9);
        $("#content1, #content2").css('z-index', 7);
        $("#"+thePart).css('z-index',9);
    });
});

When I just run the index page the code seems to stop at line 6

 $("#container").load("../index.php #container> *"

answered question

Async "problem" here, searching dupe questions...

1 Answer

1

If you want to change $object, you can do this.

$container = $("#container");
debugger;
$container = $("custom");

$container.load("../index.php #container> *"

posted this

Have an answer?

JD

Please login first before posting an answer.