Why only works on JSfiddle? [duplicate]

穿精又带淫゛_ 提交于 2019-12-02 12:24:43

You're running a script before the DOM is loaded. Either run the script after, or put it in $(document).ready().

<script type="text/javascript">
  $(document).ready(function() {
    $("#right1, #left3").on("click", function() {
        // This fires when 'right' is pressed on content 1,
        // or 'left' is pressed on content 3. In both cases
        // we want to move to show content 2.
        $("#content-container").css({left: "-100%"});
    });

    $("#left2").on("click", function() {
        // This fires when 'left' is pressed on content 2.
        // We want to move to show content 1.
        $("#content-container").css({left: "0%"});
    });

    $("#right2").on("click", function() {
        // This fires when 'right' is pressed on content 2.
        // We want to move to show content 3.
        $("#content-container").css({left: "-200%"});
    });
 });
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!