1

I usually don't program in jQuery so I'm a big newbie. I got an HTML input form (type=text) and I want that when website is loaded, the value of the textbox should change.

I got this in fill-in.php file:

<script src="fill.js"></script>
<body>
<label class="txtlabel">Username/Email</label>
<input id="username" value="Moin" type="text" name="login-username">
<label class="txtlabel">Kennwort</label>
<input id="kennwort" value="Passwort" type="password" name="login-password">
</body>

And in fill.js file I wrote this:

$(document).ready(function(e) {
    $('#username').val('some random text')
});

fill.js is correctly linked to my fill-in.php file.

Can someone give me a hint where I made a mistake?

Cheers

roemel
  • 3,247
  • 4
  • 29
  • 52

3 Answers3

2

Add this in your header section

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Satinder singh
  • 10,100
  • 16
  • 60
  • 102
1

If you're planning to use jQuery, the very first thing you need is the library. You can reference it from a CDN or download it:

http://jquery.com/download/

<!-- CDN reference (Google) -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="fill.js"></script>
emerson.marini
  • 9,331
  • 2
  • 29
  • 46
1

you need to include the jquery library before the fill.js, you can download it from the jQuery site or use a CDN version as given below

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="fill.js"></script>
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531