Ask away

Why this javascript code doesn't work for the NEST component?

Patri 01/11/17 03:31

276 views

Question CategoryComponent,Form,Properties

Number of completed projects0

Question StatusUnsolved

  • JS code
  • html
  • input field

Question

I have a javascript code to hide an element input field depending on the value in a hidden field <script type="text/javascript" charset="utf-8"> $('#ccType').change(function(){ if($(this).val() == 'maestro') $('#cvv').closest('.name').hide(); else $('#cvv').closest('.name').show(); }); </script>

Answers

2
Tom 01/12/17 21:07

You do not have a class of "name" thus the closest cannot find a match... Try this instead: <script type="text/javascript" charset="utf-8"> $('#ccType').change(function() { if ($(this).val() == 'maestro') $('#cvv').hide(); else $('#cvv').show(); }); </script>

Gail 01/13/17 06:08

I have used the same script in another html which is almost similar to this and it worked when.change is used since, if the hidden field value changes, then the script should work

Answer

Project

Image

Comment