-1

https://jsfiddle.net/andrewzheludkov/o5hr4gtx/3/ enter code here I have working example of code - if you change TYPE select in the middle to select, radio, checklistbox for example - the fields will react changing disabled states.

But with jquery 3.2.1 not touching anything else - it is not working, i cant get why. Thanx ahead!

  • 2
    Please add the code to the question as code, not as link – serge1peshcoff Dec 26 '17 at 19:00
  • 1
    And in 3.2.1, for the record, `.attr()` as a getter is deprecated. The console is warning you of that... – Snowmonkey Dec 26 '17 at 19:04
  • @Snowmonkey seriously? can you give us the link? – plonknimbuzz Dec 26 '17 at 19:05
  • 1
    React + jQuery is a mistake bound to happen because jQuery manipulates/mutates/changes the DOM, and React works with the Virtual DOM (a copy of the DOM). You must vet your jQuery seriously and hard when incorporating it and use it minimally as React can do nearly anything jQuery can. See here: https://stackoverflow.com/questions/46851070/jquery-selectors-with-react-is-ok – fungusanthrax Dec 26 '17 at 19:07
  • 1
    Sorry, I misspoke -- attr() will not return properties. It is not deprecated, I misspoke, a really good answer to the difference between the two is at https://stackoverflow.com/questions/5874652/prop-vs-attr However, if you follow back his code over at jsfiddle, there is a warning that attr() won't retrieve properties. – Snowmonkey Dec 26 '17 at 19:09
  • @Snowmonkey no problem haha – plonknimbuzz Dec 26 '17 at 19:15

1 Answers1

1

you need to change this 3 query

.attr('disabled', 'disabled') to .prop("disabled", true)

.removeAttr("disabled") to .prop("disabled", false)

and the optional:

.attr('value') to .val()

your code will run normally now

plonknimbuzz
  • 2,594
  • 2
  • 19
  • 31