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

Utilizing JQuery and Canvas to dynamically update a variable

Currently, I'm delving into learning JQuery for both fun and serious purposes. One of the mini projects I've been working on involves displaying the width of the window when the document loads. function window_width(window_w){ var window_w ...

Associate information with HTML elements

I've come across this question multiple times, but the solutions are mostly focused on HTML5. My DOCTYPE declaration is: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I'm looking t ...

Troubleshooting head.js and jQuery problems in Chrome/Firefox 5

After rendering the page, it looks something like this: <!DOCTYPE html> <html> <head> <script> head.js("js/jquery.js", "js/jquery.autocomplete.js"); </script> </head> <body> ... content ...

Discovering the position of elements in relation to their (grand^N)parent

Among my possessions are elements A and B. B has the ability to exist as a direct child of A, or there may be anywhere from 0 to N elements separating them. It is imperative that I determine how B is situated in relation to A, specifically noting the dist ...

Unable to Retrieve Response from jQuery AJAX in a Function

Having some trouble with a jQuery AJAX function that is supposed to retrieve data from a file. I can't seem to get the function to return the actual value. Any suggestions? $(document).ready(function () { function fetchData() { ...

If the cursor hovers over an image, the onmouseover function does not work properly

Currently, I am developing a PHP page to display data from a database in a tabular format. Each column in the table represents an 'ATC Station'. When active, additional data is displayed upon hovering over the cell. Everything was running smooth ...

The alignment of margins appears as intended in Opera, Chrome, and IE, but unfortunately it does not

I have exhausted all possible options, but I am still struggling to get this page to appear correctly in Firefox. When you click inside the square, a menu with images should display on the right side. It is properly aligned in every browser except for Fire ...

Get every possible combination of a specified length without any repeated elements

Here is the input I am working with: interface Option{ name:string travelMode:string } const options:Option[] = [ { name:"john", travelMode:"bus" }, { name:"john", travelMode:"car" }, { name:"kevin", travelMode:"bus" ...

Make sure to employ Bootstrap's justify-content-between and stack-to-horizontal col correctly

I am currently working on a responsive form that contains 1 label, 1 input field, and 5 buttons. Both the buttons and the input field are located under col-8. The positioning I aim for the buttons is as follows: They should start below and align with ...

Preserve marked checkboxes upon page refresh

So I created a search engine with a filter using checkboxes in a form. The filter function is working fine when I submit the form (I'm using Flask for this). However, once the results are displayed, the checkboxes that were used as filters become unch ...

Can a CSS class be designed to have a value that changes dynamically?

Let's say we have some div elements that look like this: <div class="mystyle-10">Padding 10px</div> <div class="mystyle-20">Padding 20px</div> <div class="mystyle-30">Padding 30px</div> Would it be possible to c ...

Utilizing MySql in HTML Buttons Using PHP

PHP $con=mysqli_connect("localhost","root","","mmogezgini"); $menuler = mysqli_query($con,"SELECT * FROM menuler"); while($menu = mysqli_fetch_array($menuler)) { echo "<button class=\"ust_link\" onClick=\"window.location.href ...

Calling a C# Webmethod using jQuery AJAX is not working as expected

I'm currently facing an issue calling a web method that I created. The problem lies in the fact that the ajax call isn't reaching my web method, which is puzzling to me because I have another web method in the same file with the same return type ...

Hide the menu when a user taps on an item on mobile or tablet devices

I'm facing a unique challenge and could use some guidance. The issue is with the mobile version of my website, accessible at . On tablets or mobile devices, the menu is condensed into a button. To navigate through the menu, I have to click the button ...

Utilizing jQuery and AJAX to submit a form

I'm currently facing an issue while attempting to transfer variables from an HTML form to a PHP script using jQuery and AJAX. Despite having successfully done this in the past, I am encountering difficulties this time around as PHP is failing to displ ...

Access the session on both routers

I currently have 2 different routers set up in my application: Router 1 app.post('/consultations', function(req, res) { req.session.name = 'administrator'; console.log('test', req.session.name); // the session is pro ...

"Exploring the world of WordPress: Developing plugins with Ajax for database integration and admin email

Currently, I am in the process of developing my first Wordpress contact us plugin for a website project. Here is the progress I have made so far: The plugin shows up in the plugin list on the WP dashboard Upon activation, a new table is created in the d ...

The "Splash Screen Div" page displayed during transitions and page loading

Creating a "Splash Screen Div" for a loading page involves waiting until everything is loaded and then hiding or moving the div off screen. Below is an example: index.html <div id="loading-Div"> <div id="bear-Logo"> < ...

Exploring the capabilities of utilizing filters within a ternary operator in AngularJS

Can a filter be applied to a variable in the template within a ternary operation? <img ng-src="{{ image_url && image_url|filter:"foo" || other_url }}"> In this scenario, the filter is custom-made and I prefer not to alter it to accommodate ...

Obtaining Beverage Overall with Loop

I am currently using a function to calculate the total of each drink, with a total of 5 drinks: var totalEstimate = 0; var locoCost = 0; var blackCost = 0; function calcLoco() { totalEstimate -= locoCost; locoCost = docume ...