Home >Web Front-end >HTML Tutorial >Add a click event to the html--a tag, and Firefox directly displays 0_html/css_WEB-ITnose
1. Problem Description
Added a click event to an a tag, and the page directly gave 0 as shown below
2. Problem Solution
In background debugging mode, it was found that the background method was also entered and the page was returned.
So I thought of first removing most of the content from the page, removing all the js, to see if there was a problem with some of the code. After doing so, I found that the js was completely removed, leaving only the click event, and the effect was still the same.
But there are a few strange things:
1. After entering the background method, the page becomes 0 before it is executed
2. Regardless of whether the page is in No matter what element is removed, the effect remains unchanged
3. Looking at the browser debugger, I found that the request has no response information at all
But the page has already displayed 0, and I started to think that There is a problem with the ajax request, but it still remains the same after rewriting.
Finally, I felt that there must be a problem in the page, but I didn’t know where it was, so I carefully checked the only tags on the page and eliminated some of the useless ones.
Finally, I found that there was something wrong with the href of the a tag that triggered the event. ah! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
<a class="preview" href="javascript:(0);">查看</a>
I don’t know if others can see it at a glance. I’m confused anyway. There is so much content on one page and it’s really impossible to find this thing.
I was fooled last time, so be careful in the future.
Correct writing:
<a class="preview" href="javascript:void(0);">查看</a>