1

i write me jquery script in html page like this:

<script> function pofileEditable(){
 var pFormEditable = $('#profi-form input');
 $('#pBtnSave').removeAttr('disabled', '');
 $('#pBtnEdit').attr('disabled', 'disabled');
 $('#prof-form-anrede').removeAttr('disabled', '');
 
 } </script>

How can I write it in separate file ex like that test.js and import it?

<script type="text/javascript" src="js/test.js"></script>

I don't wont to use javascript method

var edit = document.getElementById("pBtnEdit");
pgSystemTester
10.1k2 gold badges28 silver badges59 bronze badges
asked Jun 7, 2020 at 10:39

2 Answers 2

2

Best practice is to include your js file at the end of the HTML body tag, like this.

<!DOCTYPE html>
 <html>
 <head>
 <title></title>
 </head>
 <body>
 <!-- your content here -->
 <!-- If you want to use JQuery, load it before your js file here -->
 <!-- your own js file -->
 <script src = 'path/to-your-js-file/your-js-file.js'></script>
 </body>
 </html>
answered Jun 7, 2020 at 11:52
Sign up to request clarification or add additional context in comments.

Comments

1

You just import jquery first and then import your own script:

<script src="jquery-1.6.1.js"></script>
<script src="my_jquery.js"></script>
answered Jun 7, 2020 at 10:54

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.