Is it possible to hide a class by toggling it with jQuery mobile's click event?

I've come across an issue in my CSS where I have a class called hide that I applied to a textarea. When clicking a button, I want the class to be removed, but for some reason, it's not working as expected. I even added an alert in the function to check if it's triggered upon button press, and it is. However, changing it to removeClass didn't resolve the problem either.

(On another note, the textarea styling in the CSS doesn't seem to be taking effect, although it's not a critical issue)

Here's the relevant HTML:

<button id="note1btn" data-role="button">Note #1</button>
<textarea id="note1input" class="hide" rows="10" cols="50"></textarea>

CSS snippet:

#textarea {
    width: 100%;
    height: 100%;
    font: 1em arial;
    color: rgba(50, 82, 50, 1.0);
}

#textarea:focus {
    color: rgba(50, 82, 50, 1.0);
    border: 2px solid #96c56f;
    box-shadow: 0px 1px 1px #888888;
}

.hide {
    visibility: hidden;
    height: 1px !important;
    padding: 0px !important;
    margin: 0px !important;
}

Javascript function:

$(document).ready(function () {
    note1btn.addEventListener("click", displayNote);

//DISPLAY NOTE
    function displayNote() {
        alert("TEST");
        $("note1input").removeClass("hide");
    }

});

Answer №1

Don't forget to include the '#' symbol in your jQuery selector, it's crucial for proper targeting.

$("note1input").removeClass("hide");

Make sure to change the code like this:

$("#note1input").removeClass("hide");

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

The data source is having trouble connecting to the updated JSON format due to issues with pagination

I'm utilizing pagination.js to fetch asynchronous data using the code below. $('#demo').pagination({ dataSource: 'https://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?&ap ...

Utilizing the_content alongside a data attribute

Hey everyone, I'm currently working on storing the content of my posts in a data attribute for later use with jQuery. Here is the code I've been using: <div class="test" data-title="<?php the_title() ?>" data-content="<?php the_conte ...

Anticipated a JavaScript module script, but the server returned a MIME type of text/html as well as text/css. No frameworks used, just pure JavaScript

I have been attempting to implement the color-calendar plugin by following their tutorial closely. I have replicated the code from both the DEMO and documentation, shown below: // js/calendar.js import Calendar from '../node_modules/color-calendar&ap ...

Create a circle at the point where two table cells intersect in an HTML document

How can I create a circular shape at the intersections of HTML tables? I am struggling to figure out a way to incorporate shapes into HTML tables. My goal is to achieve a design similar to the image shown below. I have attempted using text and spans, as we ...

Why do query values disappear when refreshing a page in Next.js? [Illustrative example provided]

In my current project, I am developing a simple Next Js application consisting of just two pages. index.tsx: import React from "react"; import Link from "next/link"; export default function Index() { return ( <di ...

Tips for creating a responsive floating page div

Hey there, I'm still fairly new to web development and have a question regarding a registration page that is displayed as a floating div above the main page. How can I ensure that this div is centered in a responsive way? The pages are separated and ...

Validation in AngularJS - Setting minimum length for textarea using ng-minlength

I am currently tackling a project that heavily relies on AngularJS for the front-end. Here's what I am dealing with: The validation requirement I am aiming for is as follows: The Next button should remain disabled unless the reason provided is at le ...

Update the content retrieved through ajax periodically

Looking to set up a periodic update for this ajax fetch function, say every 10 seconds. I've tried a few approaches but none seem to work as expected. That's why I'm reaching out here for help. So, any idea how I can refresh the content ev ...

Empty value for $_POST variable following xmlhttp request

When my code makes an xmlhttp request to a php file with an ID for record deletion from the database, I encounter an issue. The error message 'comicID' is undefined shows up when attempting to delete. This signifies that the variable containing t ...

Divide words onto separate lines and shift them out of place

I'm tackling the challenge of crafting a basic tooltip without relying on JavaScript. I'm pondering the most effective approach to achieve this. I aim to have the tooltip container accommodate dynamic text seamlessly, adjusting responsively atop ...

Unable to implement the checkCollision function within the Snake game using JavaScript

My latest project involves creating a Snake game using canvas in JavaScript. I've managed to set up most of the game, but I'm having trouble with the collision check. Whenever the snake hits itself or the wall, the game crashes because I can&apos ...

Trouble Arising from Regional Settings in my Hybrid App Developed with CapacitorJS and Vue.js

Issue with capacitor app input Correct input in chrome app I'm facing a problem related to regional settings in my mobile application, developed using CapacitorJS and Vue.js 2. The datetime-local control is appearing in a language that isn't the ...

Utilizing query parameters in Next.js

I've been working on a unique Next.js application that incorporates both infinite scroll and a search input feature. The infinite scroll functionality loads 6 additional items whenever the user reaches the bottom of the page. On the other hand, the s ...

Children transform when the parent element is being hovered

I need assistance with changing the child element when the parent is hovered over. I also want to modify an attribute of the parent at the same time. Specifically, I want the background color of #action to change and also adjust the color of the a or h1 el ...

Deactivate the ability to hold a button, but still permit clicking in HTML for mobile

I am currently developing a progressive web app for mobile devices. One feature I have implemented is the ability for users to long-press a button with their finger, triggering a popup menu that includes options like "copy link address," "copy text," and " ...

Jquery failing to function properly when scrolling

I have been attempting to implement a feature where an element changes its position to fixed after scrolling past a certain point. However, no change occurs when I scroll. In the <head> section of my code, I have included <script src="stiler/jquer ...

"Be sure to add a table to the req.body information

Building on the topics of my recent inquiries about fetching data from async functions and adding IDs to checkboxes using loops on Stack Overflow, I am faced with a new challenge. I am attempting to retrieve the checked checkboxes using Node.js and Express ...

Are you experiencing an issue with UTF8 in PHP, Ajax, or jQuery

When I insert text into my SQL INSERT statements and it is stored in the database, the displayed text does not match what was expected. For example: This is the actual text in the database: lažljivo. However, the expected text should be lažljivo (in ...

When clicked, you will be redirected to the details page

Currently, I am developing a React JS application that showcases a list of companies fetched from a Node.js/Express server in a table format. When clicking on each row, it triggers a modal to display some details about the company. The modal consists of t ...

The issue of background-attachment: fixed not functioning properly on Safari

Currently, I have the following code implemented on an element that extends 100% of the browser: #section_white { background-attachment:fixed; background-image:url(image_url_here.jpg); background-position:100% 100%; background-repeat:no-repeat no- ...