Modify the button's border color upon click action

I am looking to implement a feature where the border of a button changes when clicked once and reverts back when clicked again. This should apply individually to each of the 16 buttons with the same class. Additionally, I want to enable the ability to click on multiple buttons simultaneously or all at once.

HTML

<button onclick="TogglePkgGroups('M16.1')" class="pool" id="M16.1">M16.1</button>
<button onclick="TogglePkgGroups('M16.2')" class="pool" id="M16.2">M16.2</button>
<button onclick="TogglePkgGroups('M17')" class="pool" id="M17">M17</button>
<button onclick="TogglePkgGroups('MR17')" class="pool" id="MR17">MR17</button>
<button onclick="TogglePkgGroups('MSS16c')" class="pool" id="MSS16c">MSS16c</button>
<button onclick="TogglePkgGroups('MSS17')" class="pool" id="MSS17">MSS17</button>
<button onclick="TogglePkgGroups('MSS17c')" class="pool" id="MSS17c">MSS17c</button>
<button onclick="TogglePkgGroups('T15.0')" class="pool" id="T15.0">T15.0</button>
<button onclick="TogglePkgGroups('T15.0c')" class="pool" id="T15.0c">T15.0c</button>
<button onclick="TogglePkgGroups('T15.5')" class="pool" id="T15.5">T15.5</button>
<button onclick="TogglePkgGroups('T15.5c')" class="pool" id="T15.5c">T15.5c</button>
<button onclick="TogglePkgGroups('T15.8')" class="pool" id="T15.8">T15.8</button>
<button onclick="TogglePkgGroups('T15.8c')" class="pool" id="T15.8c">T15.8c</button>
<button onclick="TogglePkgGroups('T16.2')" class="pool" id="T16.2">T16.2</button>
<button onclick="TogglePkgGroups('T16.2c')" class="pool" id="T16.2c">T16.2c</button>
<button onclick="TogglePkgGroups('T16.5')" class="pool" id="T16.5">T16.5</button>

Answer №1

<button class="pool" id="M16.1">M16.1</button>
<button class="pool" id="M16.2">M16.2</button>
<button class="pool" id="M17">M17</button>
<button class="pool" id="MR17">MR17</button>
<button class="pool" id="MSS16c">MSS16c</button>
<button class="pool" id="MSS17">MSS17</button>
<button class="pool" id="MSS17c">MSS17c</button>
<button class="pool" id="T15.0">T15.0</button>
<button class="pool" id="T15.0c">T15.0c</button>
<button class="pool" id="T15.5">T15.5</button>
<button class="pool" id="T15.5c">T15.5c</button>
<button class="pool" id="T15.8">T15.8</button>
<button class="pool" id="T15.8c">T15.8c</button>
<button class="pool" id="T16.2">T16.2</button>
<button class="pool" id="T16.2c">T16.2c</button>
<button class="pool" id="T16.5">T16.5</button>

Javascript function:

$(function(){
 $(this).click(function(){
   $($this).toogleClass('select-pool');
 });
});

CSS for select-pool:

.select-pool{
  border-color: blue/*change it according to your preference*/
}

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

Display the value of a JavaScript variable in a Codeception Acceptance test

Is there a way to view the value of a vanilla JavaScript variable while running an acceptance test? In PHP, you can see the value of a variable in debug using $I->seeMyVar($var), but how can you pass the value of a JavaScript variable to a PHP variable ...

Detect if the user is using Internet Explorer and redirect them to a different

My web application is having trouble rendering in Internet Explorer. In the meantime, I would like to detect if the user is using IE and redirect them to a different page specifically for IE visitors. What is the best way to accomplish this? Should I use ...

Guide on how to clear and upload personalized information to Stormpath

After receiving JSON data from my client, I am looking to store it in Stormpath's custom data using node.js with express.js: I have set up a basic post route: app.post('/post', stormpath.loginRequired, function(req, res){ var data = req.b ...

What is the best method to assign the value of a useState variable to a specific field in an array of objects for inserting data in

**I have a billing form that includes product details for the admin to fill out. One field, labeled "BillID", should automatically populate with a default value of 'Bill ID + 1' through a variable. **Below is the code: const [BillIdFetch, setB ...

New poster image displayed at the conclusion of the video (media javascript)

My current setup involves: jQuery("video").mediaelementplayer({ features: ["playpause","progress","current","duration","volume","fullscreen"], success: function (mediaElement, domObject) { mediaElement.addEventListener("en ...

Performing updates on Meteor.users collection while handling a promise rejection (leveraging fcm-push with Meteor)

My current project involves the use of an NPM package called fcm-push in order to send FCM notifications to different mobile devices based on specific messages. Everything works fine when the message is successfully sent, but if the sending fails due to th ...

click events in backbone not triggering as expected

It's puzzling to me why this is happening. The situation seems very out of the ordinary. Typically, when I want an action to be triggered on a button click, I would use the following code snippet: events:{ 'click #button_name':'somefun ...

Identify which browsers are compatible with HTML5 video autoplay detection

Having completed several projects with video backgrounds that autoplay when the page loads, I have encountered issues with mobile browsers not supporting the autoplay attribute on HTML5 videos. In these cases, an image is loaded instead of the video. To d ...

What can we do to address these strange actions? When hovering over a link, make the div fade in, and when the mouse leaves, fade out the div

Looking to create a form that appears for login when hovering over the "Log In" link with the class of "classB", and another box with information when hovering over the "My Info" link with the class of "classA". The box should fade out when the mouse lea ...

Tips for creating a column with add, edit, and delete buttons in PHP

I found this code on a website that handles pagination and search functionality. However, I am looking to enhance it by adding an icon or button in a column that will allow users to link to the edit and delete functions for specific data selected in the ta ...

Filtering Tables with AngularJS

Currently, I'm experimenting with using angularJS to filter data in a table. My goal is to load the data from a JSON file that has a structure like this (example file): [{name: "Moroni", age: 50}, {name: "Tiancum", age: 43}, { ...

I am currently working on creating a navigation bar for a webpage using the express framework and pug library. However, when I navigate to the demo page endpoint, the screen appears blank and nothing is displayed

//In the following JavaScript code, I am trying to implement basic routing navigation using express. However, when I try to insert HTML into the demo page, nothing appears on the browser screen. const path = require("path"); const app = ...

I'm having trouble getting this button and icon to align properly. How can I fix this misalignment

Take a look at the HTML code snippet I'm currently working on... <div id="projects"> <H1 class="projects">PROJECTS</H1> <div class="box"></div> <div class="box"></div> <div class="box"></ ...

Submitting an HTTP POST REQUEST with both an image and text

Is there a way to send an image with text from VueJs to an ExpressJs backend? I've currently implemented two HTTP POST requests for this process. Please note: "this.albumName" and "this.albumDesc" contain text, while the formData variable holds the ...

The Vue-router is constantly adding a # symbol to the current routes, and it's important to note that this is not the typical problem of hash and

After setting up my router file using Vue 3, it looks like this: import { createRouter, createWebHistory } from "vue-router"; import Home from "../views/Home.vue"; const routes = [ { path: "/", name: &quo ...

Having trouble passing JSON data from JQuery to ASP.Net MVC using AJAX calls?

When I try to call a WCF Service from my ASP.Net web application using jquery to test the service function GetData, I encounter an issue where the parameter value is null. It seems that I am unable to pass the data to the WCF service despite trying various ...

What is the proper way to implement history.js on my website?

Having thoroughly researched history.js on various platforms such as stackoverflow, including posts like this one, this one, and this one, as well as examining the source code, I am still struggling to grasp how to implement html5 history support while als ...

The application is experiencing issues with loading Django's CSS files properly

When working on my Django application, I've noticed that the CSS code being loaded differs from what is written in the files. What could be causing this discrepancy and how can it be fixed? ...

What is the best way to dynamically update a state that is deeply nested?

Is there a way to update the object using key: 1311 and retrieve the updated state while not knowing its exact location but only its key value? state = { iow: [ { key: 1, iow_description: "EARTH WORK", unit: null, rate: nul ...

What is the best way to activate the default action/event of an HTML link (anchor element)?

Is there a way to programmatically trigger the default action of an HTML link using JavaScript or jQuery? Essentially simulating a user click on the link. Simply using .click() does not seem to do the trick. $('#alink').click(); // nothing happ ...