javascript - disable input box on check box jquery NO onchange -


in project have check box basis if input box disable. when using click event achieve correctly when in database not behave correctly value expecting. example value 0 display disable false , disable false (default) when value 1 display disable true input not disabled here code suggestion appreciated

on click event

$('#flag').click(function() {     console.log("sumenu change on click");     if ($(this).is(":checked")) {         $('#url').prop('disabled', true);         console.log("check disble true");     } else {         $('#url').prop('disabled', false);         console.log("nocheck disble false");     } }); 

code ajax success getting value , should turn off / turn on input on data load

if (data[i].flag == "0") {     console.log("value 0 no check disble false");     $('#flag').prop('checked', false);     $('#url').prop('disable', false); } else {     console.log("value 1  check disble true");     $('#flag').prop('checked', true);     $('#url').prop('disable', true); } 

there syntax error in code,

it should , $('#url').prop('disabled', true);

not, $('#url').prop('disable', true);


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -