Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我的jQuery ui脚本不能在wordpress上运行?(加载成功,无错误)_Javascript_Jquery_Html_Wordpress - Fatal编程技术网

Javascript 为什么我的jQuery ui脚本不能在wordpress上运行?(加载成功,无错误)

Javascript 为什么我的jQuery ui脚本不能在wordpress上运行?(加载成功,无错误),javascript,jquery,html,wordpress,Javascript,Jquery,Html,Wordpress,Jquery脚本在这里(使用Jquery ui): 我的html在这里:(注意与上面脚本相关的ID为slider和sliderb的div) 我刚刚按照建议将上述脚本添加到网站中,但它仍然没有在html上留下印象,在我的本地版本中,脚本用实际的滑块替换了divs“slider”和“sliderb” 我不确定它是否有任何帮助,但我已经在这里压缩了文件:file index.html是它在本地的外观,我在网站上得到的内容可以在:vivaelectronics.com上看到 这是我的头和我加载文件的顺序

Jquery脚本在这里(使用Jquery ui):

我的html在这里:(注意与上面脚本相关的ID为slider和sliderb的div)

我刚刚按照建议将上述脚本添加到网站中,但它仍然没有在html上留下印象,在我的本地版本中,脚本用实际的滑块替换了divs“slider”和“sliderb”

我不确定它是否有任何帮助,但我已经在这里压缩了文件:file index.html是它在本地的外观,我在网站上得到的内容可以在:vivaelectronics.com上看到

这是我的头和我加载文件的顺序,这有问题吗

<head>

<meta charset="<?php bloginfo( 'charset' ); ?>" />

<title><?php woo_title(''); ?></title>
<?php woo_meta(); ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo( 'stylesheet_url' ); ?>" media="screen" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />



<?php
wp_head();
woo_head();
?>

<link rel="stylesheet" type="text/css" href="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-ui.css">
<script src='http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-1.6.2.min.js'>
</script>
<script src="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/myscript.js">
</script>
<script src="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-ui.js">
</script>

</head>


jQuery的全局
$
快捷方式不可用,您可以使用
jQuery
而不是
$
调用其函数,因为jQuery没有冲突包装


wordpress调用
jQuery.noConflict()
默认情况下,jQuery使用$作为jQuery的快捷方式<因此您必须用jQuery word替换$。。。。请参见

那么在脚本中,我是否要用Jquery替换所有的$?抱歉,如果这是一个基本问题,这是我第一次尝试编写Jquery!没问题,是的,您肯定应该用
Jquery
;)替换每个
$
)我刚刚重新检查了你的全部代码,你可以安全地用你最喜欢的文本编辑器替换所有的
,用
Jquery
替换
$
。我编辑了原始问题并添加了上面的脚本和你推荐的更正,这是你的意思吗?我刚刚将其添加到网站上,但它仍然没有给html留下深刻印象,在我的本地版本中,脚本用实际的滑块替换了divs的slider和sliderb。我不确定它是否有帮助,但我已经在这里压缩了文件:index.html是它应该是什么样子,我在网站上看到的内容可以在以下位置看到:Wordpress使用jQuery无冲突模式让许多类似的网站充满了问题。我建议,在你弄清楚这是怎么回事之前,先注销Wordpress的jQuery,然后在Google的CDN上使用jQuery。我在上面添加了脚本,并按照你的建议进行了更正。这就是你的意思吗?当然可以,用jQuery替换$,注意jQuery不同于jQuery,永远记住Javascript是区分大小写的语言:)
<div class="wrappernew">
        <div class="colThree" style="margin: 0px 0 20px 0px; ">
    <div id="contenta">
                <form method="post" name="quoteme" enctype="multipart/form-data">
            <div id="quoteme">
                        <div id="slider"> </div>
                        <label for="amount"> </label>
                        <input name="one" style="width: 400px;" type="text" id="amount" value="0" disabled="disabled" />
                        <label for="price"> </label>
                        <input name="onea" type="text" id="price" value="0" disabled="disabled" />
                        <div id="sliderb"> </div>
                        <label for="amountb"> </label>
                        <input name="two" style="width: 400px;"  type="text" id="amountb" value="0" disabled="disabled" />
                        <label for="priceb"> </label>
                        <input name="twoa" type="text" id="priceb" value="0" disabled="disabled" />
                        <p class="pricepara"> You spend £
                    <label for="total" id="totalprice" style=""> </label>
                    <input name="totalprice" type="text" id="total" disabled="disabled" style="" />
                    on cigarettes each year. </p>
                        <p class="pricepara"> By switching to Viva you could save £
                    <label for="viva" id="totalprice" style=""> </label>
                    <input name="totalprice" type="text" id="viva" disabled="disabled" style="" />
                    each year. </p>
                    </div>
        </form>
            </div>
</div>
    </div>
</div>
// JavaScript Document

Jquery(document).ready( function(slider) {

Jquery("#amount").val("How many cigarettes do you smoke a day?");
Jquery("#amountb").val("How much do you pay for a 10 pack of cigarettes?");


Jquery( function() {

    var t = {

        0: "0",
        10: "5",
        20: "10",
        30: "15",
        40: "20",
        50: "25",
        60: "30",
        70: "35",
        80: "40",
        90: "45",
        100: "50",

    }

    var d = {

        0: "0",
        0.5:"0.5",
        1:"1.00",
        1.5:"1.5",
        2: "2.00",
        2.5: "2.50",
        3: "3.00",
        3.5: "3.50",
        4: "4.00",
        4.5: "4.50",
        5: "5.00",
        5.5: "5.50",
        6: "6.00",
        6.5: "6.50",
        7: "7.00",
        7.5: "7.50",
    }


    Jquery("#slider").slider({

        value: "0",
        min: 0,
        max: 100,
        step: 10,
        slide: function(event, ui) {
            var a=Jquery("#price").val(t[ui.value]);
         update();
        }
    });


    Jquery("#sliderb").slider({
        value: "0",
        min: 0,
        max: 7.5,
        step: 0.5,
        slide: function(event, ui) {
            Jquery("#priceb").val(d[ui.value]);
             update();
        }
    });



}
);


});

function update()
{
    var a=document.getElementById('price').value;
    var b=document.getElementById('priceb').value;
    var total=((parseFloat(a)*parseFloat(b))*365)/10;
    document.getElementById('total').value=""+total;

    var c=document.getElementById('total').value;

    var viva=parseFloat(c)-(((parseFloat(a)/10)*30)*12);
    document.getElementById('viva').value=""+viva;
}
<head>

<meta charset="<?php bloginfo( 'charset' ); ?>" />

<title><?php woo_title(''); ?></title>
<?php woo_meta(); ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo( 'stylesheet_url' ); ?>" media="screen" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />



<?php
wp_head();
woo_head();
?>

<link rel="stylesheet" type="text/css" href="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-ui.css">
<script src='http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-1.6.2.min.js'>
</script>
<script src="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/myscript.js">
</script>
<script src="http://www.vivaelectroniccigarette.com/wp-content/themes/mystile/js/jquery-ui.js">
</script>

</head>