-4

I am looking to fix my function to work, whenever the element enabled. at present it's not working..

here is my try:

var x = function () {
    input = $('#username');

    if (input.prop('disabled')) {
        console.log('i am enabled'); //  how to trigger this?
    }
}

x();

$('#enable').on('click', function(){
    $('#username').removeAttr('disabled');
})

Live Demo

Note: my App always remove the attribute disabled

3gwebtrain
  • 14,640
  • 25
  • 121
  • 247

1 Answers1

1

I have created a fiddle (modified your fiddle) Hope this is the solution you require

fiddle

Code Snippet:

if (typeof attr !== 'undefined' && attr !== false) {
    console.log('i am disabled'); //  how to trigger this?
}
V31
  • 7,626
  • 3
  • 26
  • 44