javascript - It worked in jquery 1.3.0 but it will not work on 1.10.1 -
the goal onclick change input , displayed price. code below works in jquery 1.3.0 not in 1.10.1. missing? if there better way please let me know.
$(document).ready(function () { $("").click(update2); }); function update2() { var myprice = $("#price").val(); $('#displayprice').html('price: ' + myprice + ''); }
html markup -
<input type="hidden" name="price" id="price" class="item_price" value="$15.00"> </label> <div id="displayprice" name="displayprice" class="form_total">price: $25.00</div> <div class="xsshirt"> <input id="size5" class="product-attr-size" name="size" type="radio" value="xsmall" onclick="document.getelementbyid('price').value='$25.00'" /> <label for="xsmall"></label> </div> <div class="sshirt"> <input id="size1" class="product-attr-size" name="size" type="radio" value="small" onclick="document.getelementbyid('price').value='$25.00'" /> <label for="small"></label> </div> <div class="mshirt"> <input id="size2" class="product-attr-size" name="size" type="radio" value="medium" onclick="document.getelementbyid('price').value='$25.00'" /> <label for="medium"></label> </div> <div class="lshirt"> <input id="size3" class="product-attr-size" name="size" type="radio" value="large" checked="checked" onclick="document.getelementbyid('price').value='$25.00'" /> <label for="large"></label> </div> <div class="xlshirt"> <input id="size4" class="product-attr-size" name="size" type="radio" value="xlarge" onclick="document.getelementbyid('price').value='$30.00'" /> <label for="xlarge"></label> </div> </div>
in older versions of jquery, $("")
, $()
returned document
, therefore current code binding click event document.
simply update selector target document.
$(document).click(...
or better, have target parent element closer target element (whatever target element is, surely don't want catch click events on document?)
Comments
Post a Comment