Django - Javascript Not Working In Templates January 18, 2024 Post a Comment I am trying to display an input field based on user choice selection. Learning from stackoverflow, I have written the following code: Solution 1: First you have to include jquery.min.js file in html file. Then you have to keep js code in $(document).ready(function().then your code will work <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#designation').on('change',function(){ console.log($(this).val()); if( $(this).val()==="student"){ $("#students").show() } else{ $("#students").hide() } }); }); </script> <select name="designation" id="designation"> <option value="faculty">Faculty</option> <option value="student">Student</option> </select> <div id="students" style="display:none;"> <input type="file" name="uploadFile"> </div> Copy Share You may like these postsHow Can I Disable Highlighting In Html Or Js?How To Add Additional Attribute According To The TextUsing Ngresource In An Angularjs SpaHow To Place The Caret Where It Previously Was After Replacing The Html Of A Contenteditable Div? Post a Comment for "Django - Javascript Not Working In Templates"
Post a Comment for "Django - Javascript Not Working In Templates"