简体   繁体   English

如何点击角度2中的按钮?

[英]How to click a button in angular 2?

Without involving Jquery, how can the javascript of a component click an HTML button? 在不涉及Jquery的情况下,组件的javascript如何单击HTML按钮? All the documentation is for the opposite interaction of a button being on the page and handling that click, which won't work because it belongs to a ngNoForm element that the browser needs to handle itself. 所有文档都是针对页面上的按钮和处理该单击的相反交互,这将无法工作,因为它属于浏览器需要自己处理的ngNoForm元素。

You can just use a normal javascript click 您只需使用正常的javascript点击即可

Here is the doc 这是文档

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click

Here is an example code 这是一个示例代码

document.getElementById( "exit-cancel" ).querySelector( "a" ).click()

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

相关问题 如何在 Angular 7 中单击按钮时添加表单元素 - How to add form elements on button click in Angular 7 如何以编程方式单击按钮 - 也许是 Angular? - How to programmatically click on a button - maybe Angular? 如何在 Angular 中(单击)后禁用按钮 - How to disable button after (click) in Angular 如何在按钮单击时构建 Angular HTML 模板? - How to build Angular HTML template on button click? 如何在Angular JS中单击按钮添加类 - How to add class on a button click in Angular JS 如何在单击按钮时按角度 7 进行自动对焦 - How to make autofocus by angular 7 on click a button 如何在按钮单击时显示隐藏的div并隐藏Angular 2中单击的按钮? - How to display a hidden div on button click and hide the clicked button in Angular 2? Angular 8:如何在行单击时切换多行并在单击 Angular Material Table 的单个按钮上展开所有行? - Angular 8: How to toggle multiple rows on row click and to expand all rows on a single button click on Angular Material Table? 如何在单击 angular 7 中的按钮时获取下拉列表的选定值和选定文本 - How to get selected value and selected text of a dropdown on click a button in angular 7 如何在单击按钮时向 angular 表单添加更多文本框? - How do I add more textboxes to an angular form on a button click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM