conversion from javascript to jquery -
so have javascript code:
var = 7; function addnumber(number) { document.getelementbyid("display").value = document.getelementbyid("display").value + number; } function calculate() { = eval(document.getelementbyid("display").value); document.getelementbyid("display").value = a; } function erase() { document.getelementbyid("display").value = ''; }
and made jquery, not work
var $j = jquery.noconflict(); $j( document ).ready(function() { var = 7; function addnumber(number) { $j( "#display").attr( "value", ( $j( "#display").val() + number )); } function calculate() { = eval($j( "#display").val()); $j( "#display").attr( "value", a) } function erase() { $j( "#display").attr( "value", ''); } });
the full code on jsfiddle here: https://jsfiddle.net/8z6vgnqk/
don't put functions inside $(document).ready()
. since you're calling them onclick
attributes, have in global scope, have them inside function, scope local function.
and on jsfiddle, have select no wrap
frameworks menu, don't put inside window.onload
function.
var $j = jquery.noconflict(); var = 7; function addnumber(number) { $j("#display").attr("value", ($j("#display").val() + number)); } function calculate() { = eval($j("#display").val()); $j("#display").attr("value", a) } function erase() { $j("#display").attr("value", ''); }