简体   繁体   English

相同的jQuery代码在文件和控制台中的工作方式不同

[英]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? 在chrome dev工具的控制台中,它会进行动画处理,但是当我将其放在js文件中时,它只是显示元素?

thanx in advance 预先感谢

UPD UPD

<div class="b"></div> is in html <div class="b"></div>用html表示

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

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

Ok, here's a checklist: 好的,这是一个清单:

  • is the code executed on DOM ready? 在DOM上执行的代码准备好了吗?

  • does the element exist on the DOM during execution? 执行期间元素是否存在于DOM上? if not, nothing is shown. 如果没有,则不显示任何内容。

  • is the div styled or not empty? div的样式是否为空? empty divs with no padding, no background, no borders and/or 0 height don't appear. 没有填充,没有背景,没有边框和/或0高度的空div不会出现。

  • does the AJAX return a success? AJAX是否会成功返回?

  • what does the console say? 控制台怎么说? 404? 404? Cross-domain restricted? 跨域限制? Syntax error/Unexpected token at..? 语法错误/意外令牌位于..?

Could this help ? 能帮上忙吗?

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

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

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

相关问题 jQuery代码可在控制台中使用,但不能在脚本标签或外部js文件中使用 - JQuery code works in console but not in script tag or external js file jQuery函数在控制台中有效,但在代码中无效 - jQuery function works in console but not in code jQuery:.height()在.ready()中返回null,但在运行相同的代码控制台时可以工作 - jQuery: .height() returns null in .ready() but it works when run the same code console jQuery .show(); 无法在代码中工作,但可以在控制台中工作? - jQuery .show(); not working in code, but works in console? jQuery函数在一页中起作用,但在具有相同属性的另一页中不起作用(但在控制台上起作用) - jquery function works in one page but not in other with same attributes (but it works on the console) jQuery在控制台中有效,但在链接的js文件中无效 - jquery works in console, but not in linked js file jquery 在运行中的某些部分在代码中不起作用,但在控制台中起作用 - some portion of jquery in running remaining is not working in code but works in console 函数在控制台中起作用,但在jQuery中不起作用 - Function works in console but not jQuery 代码在控制台上工作,但不在脚本上 - Code works on the console but not on script 代码在控制台中有效,但在Hackerank中无效 - Code works in console but not in Hackerank
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM