admin管理员组文章数量:1391987
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
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
Share Improve this question asked Oct 2, 2013 at 12:21 roemelroemel 3,2974 gold badges31 silver badges56 bronze badges 14- 1 whether jQuery library is included.... check your browser console to see whether there are any errors – Arun P Johny Commented Oct 2, 2013 at 12:22
- 1 f12 is your friend, what is the error in the console if there is one? – epascarello Commented Oct 2, 2013 at 12:22
- 3 Close these input tags! – emerson.marini Commented Oct 2, 2013 at 12:23
- 1 @AdamWolski the right question is: Why not? It doesn't cause any harm to keep the markup well formed. – emerson.marini Commented Oct 2, 2013 at 12:25
- 2 You didn't add the jQuery library. – emerson.marini Commented Oct 2, 2013 at 12:26
3 Answers
Reset to default 2Add this in your header section
<script src="https://ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>
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./download/
<!-- CDN reference (Google) -->
<script src="//ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="fill.js"></script>
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./jquery-1.10.2.min.js"></script>
<script src="fill.js"></script>
本文标签: javascriptChange textbox value using jQueryStack Overflow
版权声明:本文标题:javascript - Change textbox value using jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744703511a2620701.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论