0
私は非常に新しいコーディングで、スタディ用のアプリケーションを作成しようとしています。私はcordovaとXcodeを使用して、アプリケーションの正しいページに要素を表示するのに問題があります。基本的には、アプリの最後にクリック可能な電話番号を表示したいのですが、要素をそのページだけに表示することに問題があります(アプリのすべてのページではなく)。私は要素を隠す方法を考え出しましたが、今は正しい場所に表示することができません。ここに私のhtmlコードは次のとおりです。Cordovaを使用した要素の表示と非表示
<script>
function show(shown, hidden) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden).style.display='none';
return false;
}
</script>
</head>
<body>
<!-- HTML Template -->
<body onload="app.initialize()">
<div class="app">
<div id="window">
<div id="question">
</div>
<div id="popup" style="display:none">
Please call any of the below:
Phone System: <a href="tel:+1-800-555-5555" class="button button-positive">800-555-5555</a>
</div>
</body>
</html>
私は私の.jsファイルに以下のものを含むことを試みたが、それはうまくいきませんでした:
var $prehashval = "";
function loop()
{
if (location.hash.slice(1)!=$prehashval)
hashChanged();
$prehashval = location.hash.slice(1);
setTimeout("loop()", 100);
}
function hashChanged()
{
var $output;
switch (location.hash.slice(1))
{
case "question":
document.getElementById('question').style.display = "";
document.getElementById('popup').style.display = "none";
break;
case "popup":
document.getElementById('question').style.display = "none";
document.getElementById('popup').style.display = "";
break;
default:
$output = location.hash.slice(1);
}
}
loop();
私も次を追加してみました:
$("#popup").hide()
$("#popup").display()
運がない。アドバイスをいただければ幸いです!ありがとうございました。