"display:none" on android browser will prevent "click" event?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"display:none" on android browser will prevent "click" event?

chun zhang
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $("#test").click();
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<input id="test" type="file" style="display:none;">
</body>
</html>


Run this code on android browser, click p will never show file dialog.
But if I remove style="display:none;", let the input show, it works.
Why?
Reply | Threaded
Open this post in threaded view
|

Re: "display:none" on android browser will prevent "click" event?

Harold Dennison
"display:none [...] causes an element to not appear in the formatting structure"

"
Please note that a display of 'none' does not create an invisible box; it creates no box at all." 


I suppose that's "why"



On Wed, Dec 4, 2013 at 2:26 PM, chun zhang <[hidden email]> wrote:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $("#test").click();
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<input id="test" type="file" style="display:none;">
</body>
</html>


Run this code on android browser, click p will never show file dialog.
But if I remove style="display:none;", let the input show, it works.
Why?

Reply | Threaded
Open this post in threaded view
|

Re: "display:none" on android browser will prevent "click" event?

chun zhang
Thanks everybody!
I tried, "display: hidden;" is not working, but "position:absolute; top:0; left:-3000px;" is worked.
I also would like to ask: "
left:-3000px;", how large negative value is the best choice? Because I tried "left:-999999999px;" is not working.


2013/12/4 Harold Dennison <[hidden email]>
"display:none [...] causes an element to not appear in the formatting structure"

"
Please note that a display of 'none' does not create an invisible box; it creates no box at all." 


I suppose that's "why"



On Wed, Dec 4, 2013 at 2:26 PM, chun zhang <[hidden email]> wrote:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $("#test").click();
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<input id="test" type="file" style="display:none;">
</body>
</html>


Run this code on android browser, click p will never show file dialog.
But if I remove style="display:none;", let the input show, it works.
Why?