Javascript jquery在我的代码中不工作
我尝试在我的网站上使用jQuery,但它似乎不起作用。这个代码不起作用。当我点击test时,它不会隐藏。请帮忙。谢谢 这是我的Html文件:Javascript jquery在我的代码中不工作,javascript,jquery,Javascript,Jquery,我尝试在我的网站上使用jQuery,但它似乎不起作用。这个代码不起作用。当我点击test时,它不会隐藏。请帮忙。谢谢 这是我的Html文件: <!DOCTYPE html> <html> <head></head> <body> <p id="#test">Hello world !</p> <script src="js/jquery.js"><
<!DOCTYPE html>
<html>
<head></head>
<body>
<p id="#test">Hello world !</p>
<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/code.js"></script>
</body>
</html>
您的html错误,请删除哈希符号:
$test表示选择id等于test的元素尝试用\\ 从
$(document).ready(function() {
$('#test').click(function() {
$('#test').hide();
});
});
<p id="test">Hello world !</p> // this is right
<p id="#test">Hello world !</p> // this is wrong
$(document).ready(function() {
$('#test').click(function() {
$(this).hide();
});
});
$(document).ready(function() {
$('#\\#test').click(function() {
$('#\\#test').hide();
});
});