Using Local variable value's in Jquery -



Using Local variable value's in Jquery -

i'v got functions @ script:

(document).ready(function () { $(".plcardfirst").change(function() { valuefirst = $( ".plcardfirst" ).val(); }); $(".plcardsecond").change(function() { valuesecond = $( ".plcardsecond" ).val(); }); });

how can utilize valuefirst , valuesecond values calculate , run if statement? many

note javascript have function scope , not block scope meaning variables declared within function keyword var can used inside function only here declaring valuefirst , valuesecond without keyword var both considered global variables means can access them time want , anywhere within if statement

you can utilize way :

$(document).ready(function () { var valuefirst,valuesecond; // declaring both variables @ origin after document.ready $(".plcardfirst").change(function() { valuefirst = $( ".plcardfirst" ).val(); }); $(".plcardsecond").change(function() { valuesecond = $( ".plcardsecond" ).val(); }); // can utilize valuefirst , valuesecond of course of study if $( ".plcardfirst" ).val() , $( ".plcardsecond" ).val(); homecoming //example if(valuefirst == valuesecond){alert('both values equal ');} });

jquery variables global local var

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -