Is it possible to create a dynamic input form that appears within a textarea using jquery?

I've designed a unique form using a textarea to display messages from users, rather than the traditional ul list. Additionally, I have included an input form where users can type their messages. My goal is to make this input form visible on the textarea when the user hovers over it, as illustrated in the image below.

<form id="message-form" action="#" method="post">
  <input id="message" placeholder="Enter your message here...">
            <button type="submit">Send Message</button>
  <button type="button" id="close">Close Form</button>
</form>

Answer №1

Forget about using jQuery in this scenario; all you need is CSS:

input.focus-actions:focus + .submit {
  display: block;
}
.submit {
  display: none;
}

Your HTML code may resemble the following structure:

<form action = "/">
    <fieldset>
        <legend>My Focus Form</legend>
        <input type = "text" class = "focus-actions" placeholder = "Write your message here..." required autofocus/>
        <footer class = "submit">
            <button type=submit>Send Message</button>
            <button>Close</button>
        </footer>
    </fieldset>
</form>

If you wish to incorporate a fading effect, consider applying animations like these:

.submit {
  -webkit-animation: fadeIn 1s ease;
  -o-animation: fadeIn 1s ease;
  animation: fadeIn 1s ease;
}
@-moz-keyframes fadeIn {
  0% {
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    opacity: 0;
  }
  100% {
    -ms-filter: none;
    filter: none;
    opacity: 1;
  }
}
@-webkit-keyframes fadeIn {
  0% {
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    opacity: 0;
  }
  100% {
    -ms-filter: none;
    filter: none;
    opacity: 1;
  }
}
@-o-keyframes fadeIn {
  0% {
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    opacity: 0;
  }
  100% {
    -ms-filter: none;
    filter: none;
    opacity: 1;
  }
}
@keyframes fadeIn {
  0% {
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    opacity: 0;
  }
  100% {
    -ms-filter: none;
    filter: none;
    opacity: 1;
  }
}

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

Adding .js extension to relative imports in TypeScript compilation for ES6 modules

This particular issue may appear simple at first glance, but determining the required settings/configurations to resolve it is not straightforward. Below are the directory structure and source code for a Hello World program: Directory Structure: | -- Hel ...

Shifting Icon to the Right within the Drawer Navigator Toolbar

While modifying the example code for Material UI's drawer navigator, I decided to enhance it by adding a notification icon and a checkout icon with the Admin Panel typography in the toolbar. However, I encountered an issue where the checkout icon app ...

steps for making a specific cell editable in tabulatorI'm happy to help

click here for image description required initializeTabulatortableBng() { let thisClass = this; let bngTableData = thisClass.tableDataWorm; function formatDecimal(cell) { var value = cell.getValue(); if (value !== null && value !== undefine ...

prompting users in a node.js application

I need help with querying the user multiple times in my Node.js application. Currently, all responses get printed out together and the first response is processed by both functions. I suspect this issue arises from the asynchronous nature of Node.js. Can s ...

Issues encountered when attempting to send Jquery Ajax due to UTF-8 conflicts

I created a JavaScript script to send form data to my PHP backend. However, the text field was receiving it with incorrect encoding. Here is the meta tag on my website: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Here&apo ...

Linkyfy.js does not function correctly with each and not statements

Trying to incorporate a linkifying script on a website, which transforms URLs in text into clickable links. Utilizing the following solution: https://github.com/SoapBox/linkifyjs To make it operational (post-download), the following steps are required: & ...

Exploring JavaScript: Accessing an array object within another object

I'm having trouble accessing an array object within an object in JavaScript. The object structure is as follows: categories: Array(5) 0: name: "Electronics" subCategories: Array(16) 0: name: "Video Games & Accessories" __typena ...

display the text content of the chosen option on various div elements

I created a subscription form that includes a category dropdown select field. The selected option's text value needs to appear 4 times within the form. It's all part of a single form. <select name="catid" onchange="copy()" id="catid" class="i ...

How to use Javascript, HTML5, and AngularJS to display and print a PDF document within a

I have a situation where I need to load a Base64 encoded PDF as a String from my server into JavaScript in my client application which is built using AngularJS and HTML5. The structure of my HTML code is as follows: <div id="printablePdfContainer"> ...

Refreshing the page to dynamically alter background and text hues

I'm currently dealing with a website that generates a random background color for a div every time it is refreshed. I have a code that successfully accomplishes this: var colorList = ['#FFFFFF', '#000000', '#298ACC', &ap ...

The impact of array splicing on data manipulation

I have a $scope array variable that I'm using to generate tabs on the front end, but I'm struggling with implementing a remove tab function. The code for removing tabs is as follows: function removeTab(index) { $scope.tabs.splice(index, 1); ...

What causes the disparity in functionality between simple html and css in an Angular 2 project compared to a vanilla html website?

When incorporating the following html/css into a new Angular project created with Angular CLI using 'ng new ProjectName', I encountered issues. Despite adding the CSS to app.component.css or styles.css and the HTML to app.component.html, the Angu ...

What steps should I take to fix the error that arises when I am using the mysql module?

When attempting to connect my local database using the node module, I encountered the following error message: Client does not support authentication protocol requested by server; consider upgrading MySQL client next is my configuration: const mysql = r ...

Using CSS to target specific attributes on standalone elements

Ever since I stumbled upon AMCSS, I have been utilizing standalone attribute selectors. Recently, I made the switch from Compass to cssnext, only to discover that syntax highlighting appears to be malfunctioning in Atom and other platforms where I tested i ...

Text Alignment in a Responsive Design

Is there a way to create a responsive container that automatically centers all items inside it on the page, regardless of the screen size? Thanks :) Images are not included in this code snippet, but here's the code: HTML <!DOCTYPE html> <h ...

Adjust the background shade of specific characters within an input text field

When a user inputs a string into a standard HTML input field (type="text"), such as "2013/13/29", and validation reveals that the number 13 is invalid in this context, I would like to visually highlight it by changing its background color to red while tu ...

How to prevent click events and still enable scrolling within a DIV using CSS/JS

Basically, I am looking to enable scrolling within a DIV while also disabling click events. Any suggestions on how this can be achieved? Appreciate any help! ...

Steps for deactivating a button based on the list's size

I am trying to implement a feature where the user can select only one tag. Once the user has added a tag to the list, I want the button to be disabled. My approach was to disable the button if the length of the list is greater than 0, but it doesn't s ...

What are some effective strategies for avoiding empty fields showing on an email form?

My HTML form is linked to a PHP Email handler, and it's working well except for one issue. When the email is delivered, it includes all fields, even the empty ones. I want it to only display filled-in fields. I tried using an IF statement that checks ...

Preventing a sprite from going beyond the boundaries of a canvas with pure JavaScript - here's how!

I am in the process of developing a game using native JavaScript, HTML, and a touch of CSS. I have two blocks called Sprites that tend to keep moving off the canvas edges when they reach them. Question: How can I utilize native JS to prevent the sprites fr ...