javascript - Jquery not disabled the parent -


input tag not disabled.this code.please me.

var input = $('input[value="' + $(this).val() + '"]'); input.prop('disabled', true);     input.parent('li').addclass('disabled'); 

you should use filter() find input value instead of using attribute value selector.

reduce set of matched elements match selector or pass function's test.

also can use closest() traverse desired parent.

script

var value = $(this).val(); var input = $('input').filter(function(){     return value == $(this).val(); }).prop('disabled', true);     input.closest('li').addclass('disabled'); 

Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

json - Zend error Connection -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -