Having some trouble with the JS code, so I decided to switch gears and focus on demonstrating some CSS concepts in

After spending around 3-4 hours trying to fix a demo using JS and CSS, I finally found half of the solution. Despite adding the CSS directly to the element which worked fine, I encountered issues when attempting to use JS.

I downloaded the jquery-1.11.3.js file and imported it as well.

The lesson I was following can be found here (ON 3:45:55).

However, upon clicking, nothing seemed to happen. Frustrating!

Login.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title> </title>
    <link rel='stylesheet' type="text/css" href='LoginCSS.css' />
</head>
<body>
    <div id="banner">Please Login!</div>
    <form>
        <div>
            <label for="name">Name:</label>
            <input type="text" name="name" />
        </div>
        <div>
            <label for="email">Email:</label>
            <input type="text" name="email" />
        </div>
        <div id="demoButton" class="default">
            Submit!
        </div>
    </form>
    <script src="jquery-1.11.3.js"></script>
    <script>
        $(function () {
            $('#demoButton').mousedown(function () {
                $(this).removeClass('default');
                $(this).addClass('shrink');
            });
            $('#demoButton').mouseup(function () {
                $(this).removeClass('shrink');
                $(this).addClass('default');
            }); 
        });
    </script>

</body>


LoginCSS.css

html {
    font-size: 16px;
    font-family: Verdana;   
}    
label {
    float: left;
    width: 75px;
}    
div {
    margin-bottom: .4em;
}    
#banner {
    background-color: lightblue;
    color: white;
    width: 100%;
    font-size : 4em;
    text-align: center;
}    
#demoButton {
    font-weight: bold;
    color: white;
    background-color: blue;
    height: 1.25em;
    width: 6em;
    text-align: center;
    padding-top: .3em;
    -webkit-user-select: none;
    cursor: crosshair;
}    
#demoButton::selection {
    color: black;
    background-color: yellow;
}    
.shrink{
    transform: scale(0.2, 0.2);
    -webkit-transform: scale(0.2, 0.2);
}    
.default {
    transform: none;
    -webkit-transform: none;
}

Answer №1

Forget about using JQuery, you can achieve the same result with CSS by utilizing :active

#demoButton:active {
    transform: scale(0.2, 0.2);
    -webkit-transform: scale(0.2, 0.2);
}

Additional resources:

http://www.w3schools.com/cssref/sel_active.asp

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

Vue.js application returning 404 error when trying to include a script in index.html

After generating my application with a simple command: vue init webpack I decided to install jquery from the node_modules folder: npm install --save jquery and then added it to my index.html page like this: <head> <script src="node_module ...

``Error: GraphQL server unable to initiate due to a failure in the module.exports

While learning GraphQL, I encountered an error when attempting to start a server. const graphql = require('graphql'); const _ = require('lodash'); const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLSchema } ...

Is it possible to execute appendChild in the context of JS-DOM-creation?

Hey there, I'm a newbie trying my hand at DOM creation. I've encountered a strange issue with appendChild - the first and second tries work fine, but I'm completely stuck on the third attempt. Here's my HTML: <html> <head> ...

Angular2/TypeScript Coding Guidelines

I am curious about the common practices and consensus among the Angular2 community when it comes to writing reusable code in TypeScript. I have gathered some information and questions related to Angular2 that I would like to discuss. Organizing Module/A ...

Is there a way I can enhance this Caption with some background effects?

I'm running into a little issue - I need to add a caption to my image with a transparent black background at 65% opacity. The caption is currently plain, without any background effects. Urgent help required. Thank you for your assistance. Here is my c ...

Issues with Ajax response being added to the table

I am encountering a technical problem with my university project. The task assigned by the professor is as follows: We need to create a static table that lists 3 domain names in order to enhance the performance of the domain availability API. <table&g ...

Sending a parameter value when onClick function is called

Currently, I am learning React JS and facing a challenge with passing parameters (like button ID or tab value) to the Tab onClick event. It appears that I'm receiving 'undefined' results when trying to pass attribute names as parameters. Ple ...

After applying CSS, I am unable to click on the radio buttons

Even after selecting the other two, it still defaults to the first one. Here is my code: input[type=radio] { display:none; } input[type=radio] + label:before { content: ""; display: inline-block; ...

Exploring different pages in an Ionic and AngularJS mobile application

I am brand new to the world of Ionic and AngularJS. I have just started working on a simple project but have hit a roadblock. My goal is, To create a login page and a register page. When a user clicks the register button on the login page, they should be ...

The development server fails to respond when initializing a new project following the NextJs documentation for an empty project

After consulting the NextJs framework documentation, I meticulously followed the setup instructions to initialize an empty project : mkdir hello-next cd hello-next npm init -y npm install --save react react-dom next mkdir pages Subsequently, I included t ...

Adjusting the scope value directly within a directive

I have a validation message that starts off hidden when the page loads due to the ng-show attribute. When the user clicks to delete an entry, the confirmation message for successful deletion appears by changing the ng-show value to false. Now, I need to h ...

What is the best way to sort my API responses to display only users who are either currently online or offline?

Hi everyone, I've made great progress on my project so far without any assistance (pretty proud of myself), but now I could use some help. I'm working on creating a tabbed menu that filters the results of my API calls to display: All users, Onlin ...

Tips for differentiating between elements with identical values in an HTML datalist using Angular

My boss is insisting that I use a datalist in our website interface to select an employee, even though there's no way to determine if the user typed in the name or picked from the list. The challenge is that the list must only display full names, but ...

Error encountered: AXIOS request failed due to XSRF-TOKEN Mismatch

My server is receiving different X-XSRF-TOKEN headers compared to the cookies being sent when I make requests 2-3 times per second using axios. let axiosInstance = axios.create({ baseUrl: "MY_BASE_URL_HERE", timeout: 20000 } ...

Animate the jQuery menu to slide both upwards and downwards, as well as shift the inner divs to the right

I'm facing a jquery issue and could use some assistance. I am trying to achieve the following: Add a class "active" to style tags when they are active. Slide up/down vertically within a div (#information - containing "About" and "Contact"). Slide le ...

The JQuery and Javascript code is malfunctioning in Internet Explorer version 6 and later

Can someone please assist me in troubleshooting why this code works perfectly in Chrome and FF, but does not continually update in IE6 & 8? $(document).ready(function () { window.setInterval(function () { $('div').each(func ...

Refresh the DATATABLE inside an AJAX call without reloading the entire page

I'm currently working with a table that utilizes the Datatable plugin. I have successfully implemented filtering and deletion functionality within the table. However, after deleting certain entries, I noticed an issue where the deleted item still app ...

When the window is resized, Div escapes from view

My issue is that whenever I resize the browser, the div moves out of the window. I am using the jQuery scroll to plugin for navigating through divs. Oddly enough, when I resize the #home div, everything seems to work fine. However, when I resize other divs ...

Issue with ExpressJS Regex not correctly matching a path

I'm currently struggling with a simple regex that is supposed to match words consisting of letters (0-5) only, but for some reason it's not working as expected. Can anyone help me figure out the correct expression and how to implement it in Expre ...

The AJAX request is not executing the xmlhttp.open method for running the script

Currently, I am making adjustments to the tutorial available at this website: http://www.w3schools.com/ajax/ajax_aspphp.asp. My modification involves storing a library of autocomplete names in a database. I have implemented a button that allows users to ...