Browser Jquery mobile示例无法在浏览器中工作

Browser Jquery mobile示例无法在浏览器中工作,browser,jquery-mobile,Browser,Jquery Mobile,我创建了一个jquery mobile示例,它在jsfiddle.net中完全正常工作,但在任何浏览器中都无法正常工作。我提供了相关链接,您可以在浏览器和JSFIDLE中进行测试 note:jsfiddle.net is the site where you can run and test the jquery examples. for brower : http://errortec.blogspot.in/ u can copy the code fro

我创建了一个jquery mobile示例,它在jsfiddle.net中完全正常工作,但在任何浏览器中都无法正常工作。我提供了相关链接,您可以在浏览器和JSFIDLE中进行测试

 note:jsfiddle.net is the site where you can run and test the jquery examples.

    for brower :   http://errortec.blogspot.in/    

    u can copy the code from the errortec.blogspot.in and place it in your html file and check it in ur browser so that u can understand the problem

你的身体没有起始标签。它应该在最后一个脚本标记和第一个div之间开始。

尝试将脚本封装在就绪函数中:

$(document).ready( function() {
//your script here
});
还有一个拼写错误,脚本标记的text属性是text/javacscript。 如果您只需为链接使用href属性,导航也应该可以工作。 对于jquerymobile,可以使用一些特定事件:pageinit、pagecreate、pageshow

更新:您的点击处理程序应添加到jQuery就绪处理程序中:


$(文档).ready(函数(){
$('#prevchild')。单击(函数(){
$.mobile.changePage($('#home'){
过渡:“幻灯片”,
相反:正确
});
});
$('#nextchild')。单击(函数(){
$.mobile.changePage($('child'){
过渡:“幻灯片”,
相反:正确
});
});
$('#login')。单击(函数(){
$.mobile.changePage($('child'){
过渡:“幻灯片”,
相反:正确
});
});
$('#返回')。单击(函数(){
$.mobile.changePage($('#home'){
过渡:“幻灯片”,
相反:正确
});
});
$(“#下一步”)。单击(函数(){
$.mobile.changePage($('child'){
过渡:“幻灯片”,
相反:正确
});
});
$('#prev')。单击(函数(){
$.mobile.changePage($('#home'){
过渡:“幻灯片”,
相反:正确
});
});
});
我已经在Chrome中尝试了你的代码,它可以与这个小改动一起工作。

在这种情况下,请尝试在windows.load()中保留javascript,如下所示:
In this case try to keep the javascript in on windows.load() as shown below :

    <script type="text/javascript">
        window.onload=function(){

            $('#prevchild').click(function() {

                    $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#nextchild').click(function() {

                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#login').click(function() {
                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#back').click(function() {
                $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#next').click(function() {
                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#prev').click(function() {
                $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });
}
window.onload=function(){ $('#prevchild')。单击(函数(){ $.mobile.changePage($('#home'){ 过渡:“幻灯片”, 相反:正确 }); }); $('#nextchild')。单击(函数(){ $.mobile.changePage($('child'){ 过渡:“幻灯片”, 相反:正确 }); }); $('#login')。单击(函数(){ $.mobile.changePage($('child'){ 过渡:“幻灯片”, 相反:正确 }); }); $('#返回')。单击(函数(){ $.mobile.changePage($('#home'){ 过渡:“幻灯片”, 相反:正确 }); }); $(“#下一步”)。单击(函数(){ $.mobile.changePage($('child'){ 过渡:“幻灯片”, 相反:正确 }); }); $('#prev')。单击(函数(){ $.mobile.changePage($('#home'){ 过渡:“幻灯片”, 相反:正确 }); }); }
主体组件在脚本执行后加载&通过使用onload()脚本,脚本将在组件加载后执行,这样组件将知道脚本
我试过了,对我很有帮助;我希望遇到同样问题的人会觉得它完全有帮助。

我不明白你的答案0上下投票接受尝试将你的脚本封装在一个就绪函数中:$(document).ready(function(){//your script here});我会检查拼写错误,因为你的答案是对的,但在这种情况下它不起作用
In this case try to keep the javascript in on windows.load() as shown below :

    <script type="text/javascript">
        window.onload=function(){

            $('#prevchild').click(function() {

                    $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#nextchild').click(function() {

                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#login').click(function() {
                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#back').click(function() {
                $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#next').click(function() {
                $.mobile.changePage($('#child'), {
                    transition: 'slide',
                    reverse: true
                });
            });

            $('#prev').click(function() {
                $.mobile.changePage($('#home'), {
                    transition: 'slide',
                    reverse: true
                });
            });
}