[英]How I can remove all the events on a HTML element?
I am building a button in the backend as follow: 我在后端构建一个按钮如下:
<?php
echo $this->myFormButton(
'add_component_restriction',
'Add',
[
'class' => 'btn btn-default add_component_restriction',
'type' => 'button'
]
);
?>
This will generate the following HTML: 这将生成以下HTML:
<button name="add_component_restriction"
id="add_component_restriction"
type="button"
value="Add" class="btn btn-default add_component_restriction"
>Add</button>
The element could be rendered as view only meaning you can view it but you can't act on it and if so I should be able to remove all the actions on it. 元素可以呈现为视图,这意味着您可以查看它,但您无法对其进行操作,如果是这样,我应该能够删除它上面的所有操作。
I did know this can be done only on the DOM level using Javascript (maybe I am wrong) maybe using .off()
or setting something like this onclick="javascript: return false;"
我确实知道这只能在DOM级别上使用Javascript(也许我错了)可能使用.off()
或设置类似这样的东西onclick="javascript: return false;"
on the element. 在元素上。
I don't know if make it disabled
or readonly
will do the job. 我不知道是否disabled
或readonly
它将完成这项工作。
Is Javascript/jQuery the only way ? Javascript / jQuery是唯一的方法吗? If there is another solution please let me know 如果有其他解决方案,请告诉我
Add the disabled
attribute. 添加disabled
属性。
<?php
echo $this->myFormButton(
'add_component_restriction',
'Add',
[
'class' => 'btn btn-default add_component_restriction',
'type' => 'button',
'disabled' => 'disabled'
]
);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.