javascript - jQuery crashes when clicked in firefox, how to solve it?
阿神
阿神 2017-06-12 09:28:47
0
2
742

点我

图片名称

图片描述

Generally speaking, it is such a simple structure. By clicking on the warpBox, the warpp.

is displayed.
$('#warpBox').on('click',function(e){ $('.warpp').css({ 'position': 'absolute', 'top': '50%', 'left': '35%' }) })

The current problem is: after clicking, the hidden p is also displayed, but it disappears after a flash. Testing in other browsers is normal, and the latest jQuery version is currently used.
How to solve it? What went wrong? Thanks!

阿神
阿神

闭关修行中......

reply all (2)
为情所困

Finally found the reason. It turns out that Firefox did not prevent this event after executing the click event, resulting in this dead look:

$('#warpBox').on('click',function(e){ e.stopPropagation(); //OK $('.warpp').css({ 'position': 'absolute', 'top': '50%', 'left': '35%' }) })
    阿神

    You should write those styles into the class, and just click to control the display. Also, if you use absolute positioning, the parent container must use relative positioning! !

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!