Home >Web Front-end >HTML Tutorial >Problem with HTML Button automatically refreshing the page_html/css_WEB-ITnose

Problem with HTML Button automatically refreshing the page_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:46:351580browse

1. Problem

<button class="am-btn am-btn-default am-btn-xs am-text-secondary" data-id="99" data-type=1><span class="am-icon-pencil-square-o"></span>修改</button>

There is such a button on the page. Every time you click this button, after executing the click event of the button, it will automatically refresh The current page.

2. Reasons

button, input type=button The difference between button in IE and w3c, firefox browser:
1. When under IE browser, button label button, input Buttons whose label type attribute is button have the same function and will not perform any operations on the form.
2. But in W3C browsers, such as Firefox, you need to pay attention. The button tag button will submit the form, while the input tag type attribute is button and will not perform any operations on the form.

3. Solution

Add a type="button" attribute to the button button.

<button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" data-id="99"  data-type=1><span class="am-icon-pencil-square-o"></span>修改</button>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn