How to change an element’s CSS class and remove all other classes on click

element wrench
how to replace water heater element
how to remove water heater element without element wrench
water heater element testing
replace water heater element without draining
how to remove water heater element that is rusted
heating element
rheem water heater element replacement

How do I handle a case in AngularJS 2 where on click of an element it needs to change its own style, and if other elements have that style they need to have it removed — preferably in one function.

Similar to Angular.js How to change an elements css class on click and to remove all others, only in AngularJS 2, using TypeScript.

Component

https://plnkr.co/edit/Q2BoU4sNnXdaJB5vrZ8h?p=preview

//our root app component
import { NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {Component} from '@angular/core';

@Component({
  selector: 'my-app',
  providers: [],
  template: `
    <div>
      <div (click)="isClassVisible = !isClassVisible;" [ngClass]="{'my-class': isClassVisible }">
        > I'm a div that gets styled on click
      </div>
      <div (click)="isClassVisible = !isClassVisible;" [ngClass]="{'my-class': isClassVisible }">
        > I also want to be styled but only when Im clicked
      </div>
      <div (click)="isClassVisible = !isClassVisible;" [ngClass]="{'my-class': isClassVisible }">
        > When one of us gets clicked the we want to be the only one with the style all others go back to normal
      </div>
       <div (click)="isClassVisible = !isClassVisible;" [ngClass]="{'my-class': isClassVisible }">
        > I'm just here cause my creator likes even numbers
      </div>
    </div>
  `,
  styles: [
  `
  .my-class {
    background-color: yellow;
  }
  `
  ]
})
class App {
  isClassVisible: false;

  constructor() {
  }

}

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}

The easiest fix to your problem is to assign a unique ID to each included element together with employing another variable to hold selected ID. The logic to turn on my-class CSS class will now be based on the selected ID.

Your new HTML template:

<div (click)="toggleHighlight(1);" [ngClass]="{'my-class': highlightedDiv === 1}">
  > I'm a div that gets styled on click
</div>

Your toggleHighlight function:

highlightedDiv: number;

toggleHighlight(newValue: number) {
  if (this.highlightedDiv === newValue) {
    this.highlightedDiv = 0;
  }
  else {
    this.highlightedDiv = newValue;
  }
}

Working Plnk: https://plnkr.co/edit/fNoXWhUhMaUoeMihbGYd?p=preview

How to Replace a Water Heater Element: A Step-by-Step Guide, How to Replace the Bottom Heating Element on a Hot Water Heater. Electric water heaters warm tap water through two heating elements, both of which are  How to Get Started with Inspect Element. Right-click anywhere on the webpage, and at the very bottom of the menu that pops up, you will see " Inspect ." Click that. Click the hamburger menu (the icon with 3 stacked dots) on the far right of your Google Chrome toolbar, click More Tools , then select


I have one hard solution to this problem:

<div (click)="onclick($event);" >
    > I'm a div that gets styled on click
  </div>

app:

class App {
constructor() {
}
onclick(event){
    var l = event.target.parentElement.getElementsByClassName("my-class");
    var count = l.length;
    for(var i=0;i<count;i++){
    l[i].className = "";
}
event.target.className = "my-class";
}
}

Plink: https://plnkr.co/edit/RHqL56GrTiV9olYE1Ars?p=preview

How to Replace an Electric Water Heater Heating Element, The cooking elements on an electric stove may need to be replaced as they age. Slow cooking times can indicate a problem. An electrical element that isn't  Remove and Replace the Oven Element Remove and Replace the Oven Element Before you begijn, identify the oven manufacturer, the oven model number or the part number on the element. The packaging on the new element will list the manufacturers, model numbers and part numbers for which it serves as a replacement.


One solution which worked for me in showing the active menu is using typescript variable name in class as in

`class="{{ text1Class }}"`  

and assign the class name in typescript.

`this.text1Class = "active";` 

or

`this.text1Class = "inactive";`

You need to have different style class like this

`.inactive {
 background-color : gray;
 padding : 10px;
}
.active {
  background-color : green;
  padding : 10px;
}`

Assign the class name inside the function

`textOneClicked() : void {
this.text1Class = "active"; // set the active class
this.text2Class = this.text3Class = this.text4Class = "inactive"; // reset other classes

}`

A working Plunker here

How to change an element, When you have a list of these elements, you can format each element in turn by using a for loop as shown. The example shows a number of common formatting tasks, including setting element margins. The example shows a number of common formatting tasks, including setting element margins.


Html code

<div [ngClass]="'first-div'">
    <h2 [ngClass]="'heading'">Log In</h2>
    <div [ngClass]="content">    
      <input type="text" placeholder="Enter User Name" name="username" id="username"#username class="in-cl">
        <i class="fa fa-user fa-edited" aria-hidden="true"></i>
      <input type="{{isPassword ? 'password':'text'}}" placeholder="Password" name="password" id="mypassword" #password class="in-cl">
        <i class="fa fa-lock fa-lock-edited" aria-hidden="true" id="lock-id" (click)="onclick()"></i>
      <button type="button" class="in-cl" (click)="credential(username.value,password.value)" >SIGN IN</button>

    </div>
    <div class="forgot">
      <a href="#">Forgot Password?</a>
    </div>  

</div>

css code

.first-div{
    width: 350px;
    border: 2px solid black;
    margin-left: auto;
    margin-right: auto;
    margin-top: 130px;
    border-radius: 5px;
    height: 400px;
    background-color: black;
    color: white;

}
.heading{
    color: white;
    text-align: center;
    font-weight: 500;
    /* background-color: white; */   
}
.in-cl{
    margin: 20px 20px 0px 20px;
    border: 2px solid white;
    border-radius: 15px;
    height: 40px;
    padding: 5px;
    width: 300px;
    outline: none;
    color: black;
    /* padding-right: 60px; */
}
::placeholder{
    color: black;
}
div button{
    background-color: #3aafa9;
    color:black;
    text-align: center;
    border: none;
}
.forgot{
    margin: 15px;
    text-align: center;
    font-weight: 550;
    color: white;
}

/* .image{
    position: absolute;
    left: 825px;
    top: 222px;
}
.lock-image{
    position: absolute;
    left: 825px;
    top: 282px;
} */
/* edited */
.fa-user:before{
    color: black;
}
.fa-lock:before{
    color: black;
} 
.fa-unlock:before{
    color: black;
}
.fa-edited{
    top: 228px;
    left: 770px;
    position: absolute;
    width: 28px;
}
.fa-lock-edited{
    top: 287px;
    left: 772px;
    position: absolute;
}
a{
    color: white;
}

ts code

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import swal from 'sweetalert2';
@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent{
  username:string="pavithra";
  password:string="8792415337abcd";
  p = document.getElementById('mypassword');

  constructor(private router:Router) {}
  credential(username:string,password:string){

    if(this.username==username && this.password==password ){
      this.router.navigate(['/home'])
      swal.fire({title:'Signed in successfully', confirmButtonColor:'#3aafa9', type:'success'})
    }
    else{
      this.router.navigate(['/login'])
      swal.fire({title:'Invalid Username or Password',type:'warning',position:'top-end'})

    }
  }
  isPassword = true;
  onclick(){
    let body = document.getElementById('lock-id')
    if (body.classList) { 
      body.classList.toggle("fa-unlock");
      this.isPassword = !(this.isPassword);
    } else {
      var classes = body.className.split(" ");
      console.log(classes)
      var i = classes.indexOf("fa-lock");

      if (i >= 0) 
        classes.splice(i, 1);
      else 
        classes.push("fa-unlock");
        body.className = classes.join(" "); 
    }


  }




}

How To Replace A Water Heater Element, Step 14: Connect electric wires to element. Tighten screws. Step 15: Replace plastic terminal protector. Step 16: Replace insulation and access cover. Tank must be properly filled with water and free of air before applying electric power to prevent element damage. Step 17: Turn ON electric power to water heater.


Hot Water Heaters : How to Change a Heating Element for Hot , Remove a screw-in type heating element by turning the element counterclockwise with a socket wrench and 1 1/2-inch socket. Some repair kits come with a socket that fits the heating element. Some repair kits come with a socket that fits the heating element.


Replacing a water heater element, I have a list s:={1, 2, 4, 7, 8} and I wish to replace every element in the list with Range[Max[s]]. I know that I could replace every element individually using ReplaceAll by doing Flatten[s /.


How to Replace the Bottom Heating Element on a Hot Water Heater , The easiest way to modify the content of an HTML element is by using the innerHTML property. To change the content of an HTML element, use this syntax: document.getElementById( id ).innerHTML = new HTML