Implement a commenting feature upon the button being clicked

When a button is clicked, I want to insert some HTML code onto my page. Here's the code that I wish to add:

    <form action="#" id="Reactie_form">
        <input id="Form_voornaam" type="text" placeholder="Voornaam" style="width: 50%"> <br>
        <input id="Form_achternaam" type="text" placeholder="Achternaam" style="width: 50%"><br>
        <input id="Form_email" type="email" placeholder="E-mail" style="width: 50%">
        <textarea id="Form_bericht" style="width: 100%"></textarea>
        <input id="files" type="file" @change="fileSelected" multiple accept=".png, .jpg, .webp, jpeg, .gif">
        <input type="button" class="sendButt" value="Verstuur" @click="submitReactie">
    </form>
    <span v-if="!files || !files.length"></span>
    <ul v-else>
        <li v-for="files in files" :key="files.name">{{ files.name }}</li>
    </ul>

I appreciate your help.

Answer №1

It looks like you're utilizing VueJS, which simplifies tasks like this!

Here's how I would approach it:

In your data() method, include the following: isClicked: false

Enclose your code within a container, like so:

<div v-if='isClicked'>
    <form action="#" id="Reactie_form">
        <input id="Form_voornaam" type="text" placeholder="First Name" style="width: 50%"> <br>
        <input id="Form_achternaam" type="text" placeholder="Last Name" style="width: 50%"><br>
        <input id="Form_email" type="email" placeholder="Email" style="width: 50%">
        <textarea id="Form_bericht" style="width: 100%"></textarea>
        <input id="files" type="file" @change="fileSelected" multiple accept=".png, .jpg, .webp, jpeg, .gif">
        <input type="button" class="sendButt" value="Send" @click="submitResponse">
    </form>
    <span v-if="!files || !files.length"></span>
    <ul v-else>
        <li v-for="files in files" :key="files.name">{{ files.name }}</li>
    </ul>
</div>

Also, add the following to your button:

<button @click='isClicked = true'>

Answer №2

Enclose your code within a wrapper div and apply a hidden class to it. This will allow you to capture the click event and dynamically change the CSS using JavaScript.

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

Delay a macro task in the user interface event listener

I created a basic react component and added an onBlur event handler that creates a new macrotask using setTimeout. function App() { const onBlur=()=>{ console.log('onBlur') setTimeout(() => { console.log('setTimeout&apo ...

How can I create a top right profile button similar to Google using AngularJS?

I am looking to implement a floating button in the top right corner of my main screen. When clicked, I want it to open a card below with an arrow pointing towards the button similar to the one on . I am currently using Angular Material and have tried using ...

Adjust the margins of an image within a text box

I've come across a simple yet widely used code online. I tried placing an image inside a textbox with the type of "text", but the image is touching the border of the empty box. Is there a way I can adjust the positioning of the image to the right to p ...

Steps for activating all iframes on an HTML page

Seeking a solution to enable all iframes on my webpage without encountering the 'refused to connect' error. Is it feasible with the implementation of a meta tag? If yes, could someone provide a code snippet for reference? ...

Receiving a NoSessionIdError issue when using Webdriver.io

Currently, I am in the process of setting up and configuring webdriver.io and Jasmine. As per the guidelines provided, my script is located at test/specs/first/test2.js (as per the configuration) and includes the following: var webdriverio = require(&apo ...

PHP Random Background Image Selector

I have a PHP code that is currently displaying a random header image every time the page is refreshed. While this works fine, I now need to add specific background-position css properties to some of the images. For instance, I would like 'headerimage ...

The Enigmatic Essence of TypeScript

I recently conducted a test using the TypeScript code below. When I ran console.log(this.userList);, the output remained the same both times. Is there something incorrect in my code? import { Component } from '@angular/core'; @Component({ sel ...

How can the outer function be connected to the resolve method of $routeProvider?

Here is a functional code snippet: $routeProvider.when('/clients', { templateUrl:'/views/clients.html', controller:'clientsController', resolve: { rights: function ( ...

Are There Other Ways to Replicate the Actions of an Anchor Link/Target Pseudo-Class?

New Inquiry: Can the onclick attribute within an <a> tag function the same way as the href attribute? In the code snippet below, I have applied <a href="#view"> to all images, and <a id="close-customlightbox" class="lb-animate" href="#!"&g ...

Why is Emmet's document snippet failing to include the "http-equiv='X-UA-Compatible'" meta tag?

While experimenting with the Emmet boilerplate in VS Code for HTML files, I noticed a discrepancy. Online tutorials show that there should be 3 meta tags when using Emmet, but when I try it in VS Code, I only see 2 meta tags. One meta tag seems to be missi ...

Using ES6, when utilizing array map in ReactJS, the function does not produce a return value

One challenge I'm facing involves mapping an array to find a specific string value. Unfortunately, despite my efforts, the map function is not returning anything as expected. class Application extends React.Component { constructor(){ super(); ...

Having trouble with Angular redirecting to the home page?

Having a bit of trouble: core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Unable to match routes. URL Segment: 'home' This is the code snippet from view.html: <div class="container"> This serves as the main app; <a rou ...

An internal server error has occurred: The code generation node is missing for the element/if/for node. Please ensure that the necessary transformations have been

Yesterday, as I was wrapping up a project, I encountered an error that has consumed my entire day today. My code was working fine, then suddenly broke. I reverted back to a point where I knew it was functioning properly, yet the issue persisted. The error ...

Retrieving a dynamic JSON object for the MusicBrainz application using AngularJS

I want to incorporate a search form into my application that sends the form result to the specified link. I am retrieving artist names from the musicbrainz JSON database using the following request: "NAME OF AN ARTIST"%20e*&fmt=json The "NAME OF AN AR ...

Instructions on how to automatically navigate to a different tab upon clicking an <a> element on a separate webpage, and subsequently display the designated tab on that

I have a button on my home page that, when clicked, should open a specific tab section on another page. The button is located on one page and the tabs are on a different page. On the second page, I have multiple tabs but will only mention one here, which ...

Isn't AJAX all about the same origin policy?

Despite my confusion surrounding the same domain origin policy and jQuery AJAX, I have noticed that when I make a GET request to a URL using jQuery, I am able to successfully retrieve the results. This goes against what I understood about the restriction ...

Getting the most out of Ziggy when integrated with Vuex

Has anyone had success using Ziggy in conjunction with Vuex? I recently incorporated Ziggy (https://github.com/tighten/ziggy) into my project to leverage Laravel's named routes within my Vue (2) files. While it works seamlessly in my Vue components, i ...

Error code 302 is triggered when attempting to retrieve an HTML file from a web address

I'm having trouble retrieving the HTML document from the URL provided below: The issue is that I keep getting a 302 response code! I am not very familiar with how this request is being handled (with the function and parameters), so I am unsure of the ...

Is there a way to invoke a function within a mat-error element?

I need to display an error message in my input field! The function will return true if both passwords match, otherwise it will return false. How can I invoke a boolean function inside mat-error! My Function: checkPasswords(): Boolean { // 'passwords& ...

Transforming a file with a node module that lacks a .js class into a browseable format

I am currently working on browserifying my module. One of the dependencies I have is on this https://www.npmjs.com/package/chilkat_win32. It is present in my node_modules folder and here is how the structure looks: https://i.stack.imgur.com/uw9Pg.png Upo ...