I cannot understand why my code doesn't work in my browsers but it works in fiddle. http://jsfiddle.net/4tafnwcj/2/
When I click on a plan, the total should output the price, however, this doesn't happen in the browser. I have checked dev tools, cleared cache, but it didn't help. I also have included all the neccessary jquery,js files, but it seems like there is something else breaking it. I don't know why. Please, help and explain what is the issue.
<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>
code:
<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>
I have removed the onclick="calculate(this);" as I don't need it, I don't have anything to calculate.
http://jsfiddle.net/3tdwak2h/4/ in fiddle my code runs, however, not in my browser. And in the Chrome console log the only error I get is Failed to load resource: net::ERR_CACHE_MISS
code
<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());
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.