显示/隐藏下载按钮,具体取决于用户是否在ios上
i have this to see if the user is on ios
if (navigator.userAgent.match(/Mac OS X/i)) {
}
but how can i hide this
<div style="text-align: center;"><a href="http://db.tt/b6ecH2Dh" id="down"><img src="img/download.gif"/></div>
if the not on an ios device?
i don't know the logic behind this but hope this will work for you with jquery:
$('div').parent('#down').css({'display':'none'});
hope this will work..
define an id for the DIV tag:
<div id="someid" style="text-align: center;"><a href="http://db.tt/b6ecH2Dh" id="down"><img src="img/download.gif"/></div>
and in JS:
document.getElementById("someid").style.visibility = "hidden";
(Edited, as ponited)
Or use this:
http://detectmobilebrowsers.mobi/
With this you can for example add speclial class to tag and use this for other porpuses.
set css property display
to none
document.getElementById("someid").style.display = "none"
it works better than visibility
property as it removes element from rendering completely while visibility
simply makes it transparent but element still takes up space on your page
if you're using jquery it's even simpler:
$('#someid').hide()
// or
$('#someid').css({'display': 'none'})
plus with jquery you can wrap it in onload hook ultra easy:
$(document).ready(function(){
if(!/ios check here/) {
$('#someid').hide()
}
})
If you want to hide it completely, try this:
<?php if(!preg_match("/(Mac OS X)/i",$_SERVER['HTTP_USER_AGENT'])){ ?>
<div>Content to hide from Mac OS X users</div>
<?php } ?>