admin管理员组文章数量:1426938
Trying to add my input onto a list but I keep getting an error. Can anyone please help me? Here is the code:
HTML:
<div class="add-item">
<input id="item-add" type='text' placeholder="Enter item to shopping list..." name="itemAdd"></input>
<button class="add-btn">Add Item</button>
</div>
<div class="item-list">
<H2>Shopping List</H2>
<ul class="shop-list">
<li><input type="checkbox">Item 1</li>
<li><input type="checkbox">Item 2</li>
<li><input type="checkbox">Item 3</li>
<li><input type="checkbox">Item 4</li>
<li><input type="checkbox">Item 5</li>
</ul>
</div>
jQuery:
$(document).ready(function(){
$(".add-btn").click(function (){
var x = $('#item-add').val();
$(".shop-list").append('x');
});
});
Trying to add my input onto a list but I keep getting an error. Can anyone please help me? Here is the code:
HTML:
<div class="add-item">
<input id="item-add" type='text' placeholder="Enter item to shopping list..." name="itemAdd"></input>
<button class="add-btn">Add Item</button>
</div>
<div class="item-list">
<H2>Shopping List</H2>
<ul class="shop-list">
<li><input type="checkbox">Item 1</li>
<li><input type="checkbox">Item 2</li>
<li><input type="checkbox">Item 3</li>
<li><input type="checkbox">Item 4</li>
<li><input type="checkbox">Item 5</li>
</ul>
</div>
jQuery:
$(document).ready(function(){
$(".add-btn").click(function (){
var x = $('#item-add').val();
$(".shop-list").append('x');
});
});
Share
Improve this question
asked Sep 16, 2015 at 4:50
David TrinhDavid Trinh
2891 gold badge5 silver badges17 bronze badges
8
- did you include jQuery in the page... – Arun P Johny Commented Sep 16, 2015 at 4:50
- have you included jquery file – Mudassir Hasan Commented Sep 16, 2015 at 4:50
- And if you think you've included it, check it for typos. – David Commented Sep 16, 2015 at 4:51
-
if included... did you use
noConflict
option... if so tryjQuery(document).ready(function($){...});
– Arun P Johny Commented Sep 16, 2015 at 4:51 -
3
@DavidTrinh: Unless you are being deliberately obfuscating,
app.js
is not jQuery. – Amadan Commented Sep 16, 2015 at 4:52
2 Answers
Reset to default 3You need to include the jQuery library. Add this in the head section.
<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>
You need to include the https://
or http://
part of the URL for a src
in the <script>
tag. Simply code.jquery./jquery.min.js
will not find it:
<script src="https://code.jquery./jquery.min.js"></script>
Also make sure jQuery is included first, before your code.
本文标签: javascriptKeep Getting an Error 39Uncaught ReferenceErroris not defined39Stack Overflow
版权声明:本文标题:javascript - Keep Getting an Error: 'Uncaught ReferenceError: $ is not defined' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745475162a2659929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论