Javascript在JS Fiddle中有效,但在Chrome / IE中无效

时间:2014-12-02 21:33:05

标签: javascript jquery html css jsfiddle

我无法理解为什么我的代码在我的浏览器中不起作用但它在小提琴中起作用。 http://jsfiddle.net/4tafnwcj/2/

当我点击计划时,总计应该输出价格,但是,这不会在浏览器中发生。我检查了dev工具,清除了缓存,但它没有帮助。我也包含了所有必要的jquery,js文件,但似乎还有别的东西打破它。我不知道为什么。请帮助解释问题所在。

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="<?=SITE_SCRIPT?>jquery.validate.min.js"></script> 
    <script type="text/javascript" src="<?=SITE_SCRIPT?>jquery.form.js"></script> 
    <script type="text/javascript" src="<?=SITE_SCRIPT?>jquery.nivo.slider.pack.js"></script> 
    <script type="text/javascript" src="<?=SITE_SCRIPT?>bootstrap.min.js"></script>            
    <script type="text/javascript" src="<?=SITE_SCRIPT?>icheck.min.js"></script> 

代码:

<div class="checkout">
                        <span id="checkout-title">Checkout</span>
                        <div class="plan-wrapper">
                        <label id="silver-plan"><input class="btn-checkbox-plan" type="radio" name="groupnine" value="699" onclick="calculate(this);"/>Cyber Security Silver Plan</label>
                        <label id="silver-plan-price">$699</label>
                        <label id="gold-plan"><input class="btn-checkbox-plan" type="radio" name="groupnine" value="999" onclick="calculate(this);"/>Cyber Security Gold Plan</label>
                        <label id="gold-plan-price">$999</label>
                        </div>
                        <div class="logo-wrapper">
                            <span id="personalized-logo">Personalized Logo</span>
                            <span id="logo-price">$49.99</span>
                        </div>
                        <div class="tax-wrapper">
                            <div class="wrapper-a">
                            <span id="tax">Tax + Processing</span>
                            <span id="tax-price">$0.00</span>
                            </div>
                        </div>
                        <div class="total-wrapper">
                            <div class="wrapper-b">
                            <span id="total">Total</span>
                            <output type="number" name="price" id="output"></output>
                            </div>
                        </div>
                        <div class="controls submit-btn">
                            <input  type="submit" value="Checkout" />
                            <input  type="reset" value="Clear" />
                        </div>
                        <div class="controls back-btn">
                            <input  class="back-button" type="button" value="Back" />
                        </div>
                    </div><!--/.checkout -->

的.js

<script>
  $(document).ready(function(){
    $(document).on("click", ".btn-checkbox-plan", function(e){
     //alert();
    if($(this).is(':checked')){

        $("#output").html($(this).val());
     }

   });  

});
</script>

1 个答案:

答案 0 :(得分:0)

我删除了onclick =“calculate(this);”因为我不需要它,我没有任何可以计算的东西。

http://jsfiddle.net/3tdwak2h/4/但是,我的代码运行,而不是在我的浏览器中。在Chrome控制台日志中,我得到的唯一错误是无法加载资源:net :: ERR_CACHE_MISS

<div class="checkout">
                        <span id="checkout-title">Checkout</span>
                        <div class="plan-wrapper">
                        <label id="silver-plan"><input class="btn-checkbox-plan" type="radio" name="groupnine" value="699" /> Silver Plan</label>
                        <label id="silver-plan-price">$699</label>
                        <label id="gold-plan"><input class="btn-checkbox-plan" type="radio" name="groupnine" value="999" /> Gold Plan</label>
                        <label id="gold-plan-price">$999</label>
                        </div>
                        <div class="logo-wrapper">
                            <span id="personalized-logo">Personalized Logo</span>
                            <span id="logo-price">$49.99</span>
                        </div>
                        <div class="tax-wrapper">
                            <div class="wrapper-a">
                            <span id="tax">Tax + Processing</span>
                            <span id="tax-price">$0.00</span>
                            </div>
                        </div>
                        <div class="total-wrapper">
                            <div class="wrapper-b">
                            <span id="total">Total</span>
                            <output type="number" name="price" id="output"></output>
                            </div>
                        </div>
                        <div class="controls submit-btn">
                            <input  type="submit" value="Checkout" />
                            <input  type="reset" value="Clear" />
                        </div>
                        <div class="controls back-btn">
                            <input  class="back-button" type="button" value="Back" />
                        </div>
                    </div>

的.js

   $(document).ready(function(){
     //alert();
   $(document).on("click", ".btn-checkbox-plan", function(e){
     if($(".btn-checkbox-plan").is(':checked')){

    $("#output").html($(this).val());
}

   });  

 });