0

I'm new to Javascript and Jquery and trying to learn how to dinamically add elemnts to my html.

My HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Academic Calculator</title>
    <meta name="Calculator" content="Academic Calculator">
    <link rel="stylesheet" href="Calculate.css">

</head>
<body>
    <script src="CalculatorLogics.js"></script>
    <div>
        <form>
                First Name:<br>
                <input name="first-name">
                <br>
                Last Name:<br>
                <input name="last-name">
                <br>
            <hr>
        </form>
    </div>
    <div class="courses">
        <button type="button" onclick="createNewCourses()">Add Course</button>
    </div>
</body>
</html>

and my Javascript:

function createNewCourses() {
    $(".courses").append("<input type='text>");
}
1
  • I know there was an edit approved, but it invalidates the answers by fixing the problem. As such, I've filled it back. Commented Apr 29, 2018 at 15:20

1 Answer 1

2

You have made a mistake 'text replace with "text"

function createNewCourses() {
    $('.courses').append('<input type="text">');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>


   <div>
        <form>
                First Name:<br>
                <input name="first-name">
                <br>
                Last Name:<br>
                <input name="last-name">
                <br>
            <hr>
        </form>
    </div>

    <div class="courses">
        <button type="button" onclick="createNewCourses()">Add Course</button>
    </div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.