简体   繁体   English

如何删除输入类型的属性以单击? Angular?

[英]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"  
}

as @AlphaMirage said you can use removeAttribute function正如@AlphaMirage所说,您可以使用removeAttribute function

if you want to remove inputmode just pass the element into your function and use removeAttribute like:如果您想删除inputmode ,只需将元素传递到您的 function 并使用removeAttribute如下:

in your .ts file在您的.ts文件中

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

and in your .html在你的.html

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

working StackBlitz 工作 StackBlitz

I don't know angular but you can do this with plain javascript:我不知道 angular 但你可以用普通的 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!原来这不是答案!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何删除禁用的属性并聚焦输入Angular 5? - How to remove disabled attribute and focus input Angular 5? 如何通过单击按钮从 Angular 材料输入中删除所需的验证器? - How to remove the required validators from Angular material input on click of a button? 如何通过角度2中的函数触发事件单击输入类型=“文件”? - how to trigger event click at input type=“file” by function in angular 2? Angular 2 如何从多个输入类型文件中删除文件? - Angular 2 How to remove file from files of input type file multiple? 当我单击提交输入时,如何从输入同级中删除“禁用”属性 - How to remove the attribute “disabled” from input siblings when i click on a submit input Angular - 如何在输入为空时关闭/删除搜索输入,单击外部输入元素或按 esc - Angular - How to close/remove search input when input empty, click outside input element or press esc 如何在隐藏输入中以逗号分隔的列表中单击来添加/删除属性值 - How to append/remove attribute value on click to/from the comma separated list within hidden input 如何使用ng-单击超链接从表单输入文本字段中删除/添加属性 - How to remove/ add an attribute from a form input text fields using ng-click on a hypelink 单击时如何添加/删除属性 - How to add / remove attribute when click 如何使用jQuery从输入中删除选中的属性 - How to remove checked attribute from an input with jQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM