vagored61
vagored61

Reputation: 43

How to remove attribute on input type to click? Angular?

I need to remove on click input type attribute. Example:

<input type="number" (click)="removeInputModeAtribute()" inputmode="none">

removeInputModeAtribute(){ 
//remove inputmode="none"  
}

Upvotes: 0

Views: 1845

Answers (2)

JSmith
JSmith

Reputation: 4808

as @AlphaMirage said you can use removeAttribute function

if you want to remove inputmode just pass the element into your function and use removeAttribute like:

in your .ts file

removeEl(el:HTMLInputElement) {
  el.removeAttribute('inputmode');
}

and in your .html

<input type="number" #el (click)="removeEl(el)" inputmode="none">

working StackBlitz

Upvotes: 1

user14983900
user14983900

Reputation:

I don't know angular but you can do this with plain javascript:

function remove(what) {
  alert('You Will Only See This On The First Click!')
  what.removeAttribute("onclick");
}
<button onclick='remove(this)'>BUTTON</button>

Turns out this is not the answer!

Upvotes: 0

Related Questions