최근 jQuery를 배우기 시작하면서 문제가 발생했습니다. jQuery의 코드 형식은 C/C++의 배경에서 나에게 익숙하지 않기 때문에 생소합니다.올바르게 사용하는 방법 .append()
내 문제는 .append()가 단순히 추가되지 않는 것 같습니다. 나는 최근에 jQuery에서 팝업을 만들기 위해 스크립트 작업을하고 있으며, body에 요소를 추가해야했습니다. 아무 일도하지. 추가 테스트 후 .append()가 작동하지 않는 것 같습니다. 내 결론은 아마 그것을 잘못 사용하고 있지만 나는 어떻게 깨닫지 못한다.
$('#contact').click(function (e) {
$('#about').append('<h1>test</h1>');
e.preventDefault();
});
편집 1 : HTML은 HTML 만 중 일부는 공간 (I가 추가있어 지역에서 HTML)를 저장하기 위해 포함 된
<!DOCTYPE html>
<html>
<head>
<title>Canteen Mate</title>
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Ubuntu">
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class = "nav_wrapper" id = "nav_wrapper">
<nav>
<ul>
<li class = "current"><a href="#nav_wrapper" id = "Home" class = "nav">Home</a></li>
<li><a href="#about" id = "About" class = "nav">About</a></li>
<li><a href="#contact" id = "Contact" class = "nav">Contact</a> </li>
</ul>
</nav>
</div>
<div class = "wrapper">
<img src="images/newfood.jpg" alt="Food" class="luncho">
<div class = "text">
<h1 class = "motto">Ordering from the canteen has never been so simple<br>
<p class = "motto-description" id = "about">Order food from your canteen from
anywhere as long as you have data.</p></h1>
</div>
</div>
을 요청했다.
<script>
요소가 맨 아래에 있습니다.
그게 핵심이 될 것 같습니다, 잘 발견 – NachoDawg
아, 정말 고마워요! 내가 바보이기 때문에 나는 href를 보았다.내 커피를 잊어 버렸어! 감사합니다. @eisbehr –
안녕하세요, @JamesBalajan! – eisbehr