简体   繁体   中英

same jquery code works differently in file and console

why when I execute

$(".b").show(1000);

in console of chrome dev tools it animates but when I put it in js file it's just displays element?

thanx in advance

UPD

<div class="b"></div> is in html

    $.ajax({
        url: "/some/url.php",

        }).done(function ( data ) {
            $(".b").show(1000);
        }); 

Ok, here's a checklist:

  • is the code executed on DOM ready?

  • does the element exist on the DOM during execution? if not, nothing is shown.

  • is the div styled or not empty? empty divs with no padding, no background, no borders and/or 0 height don't appear.

  • does the AJAX return a success?

  • what does the console say? 404? Cross-domain restricted? Syntax error/Unexpected token at..?

Could this help ?

$.ajax({
        url: "/some/url.php",

        }).done(function ( data ) {
            $(".b")live().show(1000);
        }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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