Is there a way to reveal multiple inputs by simply pressing a button?

Currently, I am working on developing a website using HTML, CSS, and JavaScript. As part of the process, I am looking to implement a login interface. I have already included some input fields and written a sign-in.js script that verifies whether a user has clicked on my designated symbol for logging in. Everything is functioning properly except for one key aspect: displaying the input fields when someone clicks on the "user-cog" button. Here is a snippet of my code:

Index.html:

<nav id="main-nav">
    <i class="fa fa-bars" aria-hidden="true"></i>
    <ul>
      <a href="#home"><li> Home </li></a>
      <a href="#about"><li> About </li></a>
      <a href="#work"><li> Work </li></a>
      <a href="#contact"><li> Contact </li></a>
      <i class="fas fa-users-cog", id="user-cog"></i>
    </ul>
    <form id="sign-in">
      <input class="input_text" type="text" tabindex="1" placeholder="E-Mail"><br>
      <input class="input_text" type="text" tabindex="2" placeholder="Password"><br>
      <input id="sign-in-button" class="button" type="submit">
    </form>
  </nav>

sign-in.js:

$(document).ready(function() {
  $(".fa-users-cog").on("click", function() {
    $("header nav ul i").toggleClass("sign-in-open");
  });
});

style.css:

#main-nav ul i.sign-in-open{

  /*YOUR CODE TO SHOW THE INPUTS SHOULD GO HERE*/

}

I would greatly appreciate any assistance in solving this issue. Should you require any additional information from me, please let me know.

Sincerely, Daniel.

Answer №1

Instead of just adding the class to your button, make sure to toggle the class on the form or inputs and then style them accordingly using the following code:

      $(".fa-users-cog").on("click", function() {
         $(document).ready(function() {
            //Toggle a class for the form
            $("#sign-in").toggleClass("open");
         });
     });

You also need to adjust the styles like this:

        //Hide the form when it doesn't have the 'open' class
        #sign-in{
            display:none;
        }
       #sign-in.open{
           display:block;
       }

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

What is the method to render certain text as bold using a json string?

I need assistance with concatenating two strings in react while ensuring that the first string is displayed in bold, while the second one remains unchanged. The first string I want to emphasize is stored in a JSON file, and the second string comes from an ...

What is the best way to showcase several cards containing data retrieved in Vue?

I have a component called Beers and another component called BeerDetailList. In the second component, I'm using a Bootstrap card to display image, title, etc. My issue is that I want to display these cards in multiple rows and columns. I've tried ...

Mobile device does not respond to HTML button click

Currently, I am developing a web application. On one of my HTML pages, I have the following code snippet: <div class="div2"> <button id="buttonid" type="button" class="btn-submit pull-right" onclick="alert()">BOOK NOW</button> <d ...

Variety of positions for jquery ui tooltips

When incorporating Jquery UI tooltips into my project, I encountered a challenge with positioning the tooltips throughout the entire document except for specific divisions with a certain class. $(document).not(".t_l_overview").tooltip({ position: { ...

React Component failing to display properly in Bootstrap tab

Why are my tabs and tabpanels showing up correctly, but the furniture components are not being rendered? Is there a fundamental issue with how I am trying to implement this? <Tabs defaultActiveKey={Object.keys(this.state.fTypes)[1]} transition={fal ...

What is the best way to prioritize the display of custom login buttons based on the last button used for login?

I have implemented 4 different login methods for my app, each with its own associated component. I am looking to rearrange the buttons based on the last used login method. I already have a function to determine the last login method. let lastSignedInMetho ...

Unchecking an available item observable in Knockout.js when clicking on a selected item

When you click on the elements in the top list, a selection is made. If you click on the elements in the bottom list, it will be removed from the list. However, the checkbox in the top list is not being unchecked. How can this issue be resolved? functio ...

Is it Possible to Modify CSS Dynamically within an Angular Directive?

I am currently developing a directive for an input field of type text. My goal is to have the width of this field expand dynamically if the text exceeds the size of the input field. Below is the code snippet for my directive: .directive('dynamicInput ...

React - Insert a Component in-between two already rendered components

As a React beginner, I am working on creating a dynamic form that allows users to add and remove fields. However, I encountered an issue with rendering after adding a new row (field). Below is my Row Component, which serves as a template filled with props ...

Obtaining and storing multiple checkbox selections in a database using a JSP page

If users are required to input data on the first page, such as City, Country, and URL of the destination, and they need to select the type of destination from options like Winter, Christmas, and Summer (max 2 selections), how can these results be connected ...

Upon initiating a second user session, NodeJS yields contrasting MySQL outcomes

As a novice in NodeJS and Express, I find myself stuck on what seems to be a trivial issue. Despite my best efforts, I have been unable to resolve the problem on my own. My aim is to create a basic web application that allows user authentication and displ ...

Adjust the spacing of a div based on the fluctuating height of another dynamically changing div

Is it possible to dynamically adjust the margin of a div using jQuery or JS? Currently, I have set a margin on a div by calculating the height of a container that includes images. var articleImageHeight = $('.slides_control').height(); $(' ...

Is there a way to arrange an array based on the product or quotient of two values?

I'm working with an array of posts, each containing data on 'views' and 'likes', along with the user IDs associated with those likes. My goal is to sort this array based on the like rate. However, my current approach seems to be i ...

When navigating through a view in backbone.js, ensure to include an argument in the routing process

Looking to include an argument while routing within a Backbone.js application Below is the script: var AppRouter = Backbone.Router.extend({ routes: { 'toolSettings/(:action)' : 'toolSettings' } }); var initialize = function ...

React CSS modules are a powerful tool for styling components in

Having some difficulty with css modules in react, I am unsure how to utilize react modules dynamically. import classnames from 'classnames' import styles from './hover.module.css /// /// const [flashElements,setFlashElements]=useState(elemen ...

Is it possible to set custom spacing for specific breakpoints in a Material-ui theme?

Currently, I am in the process of ensuring that my Material-ui + React dashboard is responsive and well-styled for various screen sizes. Within my custom theme, I have set the spacing to 8: import { createMuiTheme } from '@material-ui/core/styles&ap ...

What is the process for filtering out a particular version of an npm package?

Here is my current configuration: "@vue/test-utils": "^1.0.0-beta.25" Can anyone recommend a way to exclude a particular version of this package while still using the caret ^ notation? I specifically need to exclude version 1.0.0-beta.31 as it has cause ...

Tips for locating the index while performing a drag and drop operation between two different containers

Can anyone help me figure out how to determine the exact index of an item when performing a jQuery drag and drop between two containers? I'm having trouble identifying the correct index, especially when it's dropped outside of its original contai ...

Updating ngModel using the value retrieved from a service call

After experiencing dissatisfaction with Angular's form validation, I decided to develop my own solution. However, I have encountered a perplexing issue that has me at a loss. Here is how my setup looks: I employ a directive to create a new form. Th ...

Choose the child nodes upon selecting the root node

I am trying to implement a 2-level material-ui treeview where selecting the root node should automatically select all child nodes as well. Does anyone have suggestions on how to achieve this with material-ui treeview? For more information, please visit ma ...