Home  >  Article  >  Web Front-end  >  What is the difference between display:none and remove in css in JavaScript?

What is the difference between display:none and remove in css in JavaScript?

黄舟
黄舟Original
2017-07-24 09:48:002786browse

Write a mouse-over display and leave the disappearing js
Get the data in js when the mouse is hovered, use .append(pop) to paste it into the dom, and display it in the .Micro_video_imgne tag.
Use remove to make the pop disappear when the mouse is moved.
But there is a problem when using remove. When the mouse hovers over pop, the pop label will flash and flash, because the added style (.pop) is within the mouse hover label (.Micro_video_img).
If you use css (display: none), the effect can be achieved perfectly. But the problem is that the tags of the page will be added.

$("body").on("mouseover",".Micro_video_img",function(){
    var pop="<div class=&#39;pop&#39;><a href=&#39;#&#39; class=&#39;Micro_video_a font_e&#39;>橡皮雕刻章子-周杰伦</a><div class=&#39;taolun&#39;>"+
    "<s class=&#39;taolun_icon icons&#39;></s>53</div><div class=&#39;like&#39;><s class=&#39;like_icon icons&#39;></s>230</div></div>";

        $(this).append(pop);

});

$("body").on("mouseout",".Micro_video_img",function(){
    $(this).children("div.pop").remove();
});

Cause of flickering: The mouseover event is triggered when the mouse moves to the pop. After the pop is removed, the mouseout event is triggered. In fact, the two events are executed alternately, causing the page to be rendered continuously. of.
Solution: Passing through the element and its child elements will trigger the mouseover event, replace the mouseover/mouseout event with mouseenter/mouseleave.

Try changing to mouseenter

display: none Does it just mean hidden? The position is also moved out of the way. Isn't remove the node removal?

display:none->Hide this person in the house and don’t come out to see anyone
$('#dom').remove()->Keep this person completely off the face of the earth Disappear
visibility:hidden->Many people are living on empty wages and occupying the pit
opacity:0->Wearing the emperor’s new clothes

The above is the detailed content of What is the difference between display:none and remove in css in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

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