Unable to display content when the button is triggered

I am facing an issue with hiding a div (class="login-form") and displaying it only after clicking the Login button on my HTML page using jQuery. However, despite clicking the button, the login form does not appear. Can anyone help me understand why this happens?

Thanks in advance!

HTML---------------------------------------------------------------------------

<?php /* Template Name: Virtual-tour */ ?>
<head>

<link rel="stylesheet" href="stylus/main.css"/>
<link href='https://fonts.googleapis.com/css?family=Alegreya+Sans' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- <script src=js/showLogin.js></script>
<script src=js/showCreateAccount.js></script>
<script src=js/submitLogin.js></script>
<script src=js/submitCreateAccount.js></script>
<script src=js/validate.js></script> -->

</head>

<body>

<div class="virtual-tour-media-player">

    <span> placeholder for media player</span>

</div>

<div class="instructions">

    Are you a family member or friend of a veteran on this memorial?</br></br>
    <span id="instruction-sub">
        To contribute information and memories, please Login or Create Account below.</br>
    </span>

    <button id="login">Login</button>
    <button id="create-account">Create Account</button>

</div>

<div class="login-form">
    <form>
        <input type="text" placeholder="Email Address" />
        <input type="password" placeholder="Password" />
    </form>
</div>

<script>
    $(document).ready(function() {
        $("#login").click(function(){
            $('.login-form').show();
        });

        $('#create-account').click(function{
            $(".create-account-form").show();
        });
    });
</script>

Stylus (a CSS preprocessor, very similar syntax to CSS)---------------------------------------------------

body
    color #ffffff
    background-color #292929
    font-family 'Alegreya Sans', sans-serif

.virtual-tour-media-player
    width 90%
    height 40%
    margin auto
    border 3px solid white

.instructions
    padding-top 30px
    margin auto
    margin-top 5%
    font-size 100%
    width 45%
    height 22%
    text-align center
    background-color #740600
    box-shadow 2px 2px 2px 2px #232421

#instruction-sub
    font-size 15px
    //color #4d4d4d

button
    line-height 1.8
    border none
    color #f1f1f1
    background-color #0c083e
    margin auto
    margin-top 10%
    width 40%
    height 15%


button:hover
    background-color #292929

.login-form
    display none

Answer №1

RESOLUTION: The absence of parentheses in the second .click() function (for #create-account) was causing an issue, but everything else was functioning correctly.

Answer №2

Please review your code carefully, as you appear to have forgotten to include parentheses "()" for the function #create-account.

$('#create-account').click(function(){
    $(".create-account-form").show();
});

Answer №3

Simply insert the missing closing parenthesis in your

$("#create-account").click(function() "
and everything should be functioning properly.

$(document).ready(function() {
    $("#login").click(function(){
        $('.login-form').show();
    });

    $('#create-account').click(function() { <---- don't forget "()"
        $(".create-account-form").show();
    });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How come this variable isn't recognized as 0 even though the debugger is indicating otherwise?

I am currently working on a React component that receives the total number of reviews as a prop. In cases where the number of reviews is 0, I intend to display an element indicating <div>No reviews yet.</div> If there are reviews available, I ...

Having trouble with the page redirection issue? Here's how you can troubleshoot and resolve

My goal is to restrict access to both the user home and admin dashboard, allowing access only when logged in. Otherwise, I want to redirect users to the login or admin login page. import { NextResponse } from 'next/server' import { NextRequest } ...

Obtaining Polish UTF-8 characters post-serialization of data with the use of Jquery

I created a script to send data from an HTML form to a server using an ajax request. $.ajax({ type: $(this).attr('method'), cache: false, url: $(this).attr('action'), data: $(this).serialize(), dataType: 'json& ...

Is there a way to identify the moment when a dynamically added element has finished loading?

Edit: I've included Handlebar template loading in my code now. I've been attempting to identify when an element that has been dynamically added (from a handlebars template) finishes loading, but unfortunately, the event doesn't seem to trig ...

What is the method to select a hyperlink that includes a variable in the "href" attribute and click on it?

Currently, I am in the process of creating acceptance tests utilizing Selenium and WebdriverIO. However, I have encountered a problem where I am unable to successfully click on a specific link. client.click('a[href=#admin/'+ transactionId + &apo ...

Pictures may become distorted when their width is smaller than the container

In my current project, I am facing an issue with maintaining the aspect ratios of images of different sizes. Most of them are looking good except for those whose width is smaller than the container's width of 285px. Even though some blurriness is acce ...

Choose from the select2 multiselect options and lock certain selected choices from being altered

I have coded a select dropdown with preselected options, some of which I want to keep fixed so that users cannot change them. To achieve this, I implemented the following code: <select id="select2-multiple" name="users" multiple="multiple" style="width ...

Using Node.js to retrieve child processes associated with a daemon and terminate them

I am attempting to create a node application that allows me to send the command kill -9 to all child processes of a single daemon. Just to clarify, there is one daemon running on our server. Upon startup, it initiates a process for communicating with clie ...

Retrieve the function-level variable within the while loop's else statement

Struggling with node.js, I find myself facing the challenge of accessing a variable declared at the start of a function from an else statement nested within a do while loop: function myFunction(){ var limit = 2000; var count; var total; va ...

Search form with a variety of fields that allows for searching without needing to repeat the component for each condition

I am currently facing an issue with my form that consists of multiple fields, each used to search through an API and display matching data in a table below. While I have successfully implemented this for one field, I now need it to work for all fields with ...

Creating a Dynamic Navigation Bar with HTML and CSS

I've been exploring the code on w3schools.com, and while there are some great examples, I'm struggling to understand it all. Unfortunately, there aren't any instructions on customizing the code for a third level of menus. Can someone simplif ...

Understanding the getJSON MethodExplaining how

$.getJSON( main_url + "tasks/", { "task":8, "last":lastMsgID } I'm a bit confused about how this code functions. I'm looking for a way to retrieve messages from a shoutbox using a URL or some sort of method that the function here ...

Harness the power of React ref to serve as a selector for jQuery plugins

Exploring How to Seamlessly Integrate React Ref and jQuery Library without the Need for Specified IDs on Input Fields? import $ from 'jquery'; import 'jquery.mask.js'; class PhoneComponent extends React.Component { ref = React.creat ...

Conquering Challenges Across Multiple Disciplines

Is there a solution to solving the cross domain issues that arise when trying to fetch data from a different web server on the client-side, in violation of the Same Origin policy? ...

Encountering a Problem with Image Rendering in Next.js

Issue: I am facing a problem while trying to display a react component using <Gallery images={images} />. The component itself is rendered, but the images from the array are not showing up initially. However, when I resize the screen by dragging the ...

Error TS2403: All variable declarations following the initial declaration must be of the same type in a React project

While developing my application using Reactjs, I encountered an error upon running it. The error message states: Subsequent variable declarations must have the same type. Variable 'WebGL2RenderingContext' must be of type '{ new (): WebGL2 ...

Tips for ensuring that divs resize to match the container while preserving their original proportions:

#container { height: 500px; width: 500px; background-color: blue; } #container>div { background-color: rgb(36, 209, 13); height: 100px; } #one { width: 1000px; } #two { width: 800px; } <div id="container"> <div id="one">&l ...

The replace method in JavaScript can only be used once

I'm trying to find a way to swap one string (str1) with another string (str2) whenever str1 appears in a particular div. Here's what I have managed to come up with so far: <script type="text/javascript"> $(window).load(function(){ var s ...

I am encountering difficulties with generating images on canvas within an Angular environment

I am trying to crop a part of a video that is being played after the user clicks on it. However, I am encountering the following error: ERROR DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may no ...

What is the best way to execute tests in different environments with Protractor?

Is it possible to execute specifications in various environments? Maybe by adjusting the protractor-config file? Could we do something along the lines of specs: ['../tests/*.js', server1], ['../more_tests/*.js', server2] within the ...