jQuery: if value is true without user action

Posted by Kevin Brown on Stack Overflow See other posts from Stack Overflow or by Kevin Brown
Published on 2011-01-15T23:38:18Z Indexed on 2011/01/15 23:53 UTC
Read the original article Hit count: 179

Filed under:

I want to show a div if the value of an input =='CP'.

Right now this is my code:

$(".register-type").change(function(){
    var value = $(this).val();
    if(value == 'CP'){
    $('.cp-show').show();

This works fine if they change the input, but if things get validated false and the page reloads, this input is still 'CP', but the div doesn't show...

Is there a way to correct this so that jquery checks if this is set on the page load?

© Stack Overflow or respective owner

Related posts about jQuery