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

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

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

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