【问题标题】:script not working on my android browser脚本在我的安卓浏览器上不起作用
【发布时间】:2016-08-01 09:08:38
【问题描述】:

我使用 wordpress 创建一个网站并编写了一个脚本,人们可以在其中选择一个单选按钮,然后再显示一个选项。但是脚本无法在 android 互联网浏览器上运行我做错了什么

这是表格:

<form id='form-id' action="http://trainingzuid.nl/wp-content/php/mail.php" method="post">
<table>
<tbody>
<tr>
  <td><input id='pt' name='test' type='radio' /> personal training</td>
  <td><input id='gt' name='test' type='radio' /> group training</td>
  <td><input id='bt' name='test' type='radio' /> both</td>
</tr>
<tr>
<td><div id='pur' style='display:none'>Purpose:</div></td>
</tr>
<tr>
<td><div id='gf' style='display:none'><input type='radio'> general fitness</input></div></td>
<td><div id='lw' style='display:none'><input type='radio' /> losing weight</div></td>
<td><div id='bt1' style='display:none'><input type='radio' /> both</div></td>
</tr>
<tr>
<td><div id='kb' style='display:none'><input type='radio'> kickboksen</input></div></td>
<td><div id='b' style='display:none'><input type='radio' /> boksen</div></td>
<td><div id='kkb' style='display:none'><input type='radio' /> kids kickbosen</div></td>
</tr>
<tr>
<td><div id='bf' style='display:none'><input type='radio'> ballet fitness</input></div></td>
<td><div id='ch' style='display:none'><input type='radio' /> cross hit</div></td>
<td><div id='t6' style='display:none'><input type='radio' /> training 6</div></td>
</tr>
<tr>
<td><div id='t7' style='display:none'><input type='radio'> training 7</input></div></td>
<td><div id='t8' style='display:none'><input type='radio' /> training 8</div></td>
<td><div id='t9' style='display:none'><input type='radio' /> training 9</div></td>
</tr>
<tr>
  <td><p><input type="text" name="name" placeholder="First and last name"></p></td>
  <td><p><input type="text" name="email" placeholder="e-mail adress"></p></td>
</tr>
<tr>
  <td><p><input type="text" name="phone" placeholder="Phonenumber"></p></td>
  <td><p><input type="text" name="message" placeholder="additional message"></p></td>
</tr>
</tbody>
</table></center>
  <center><input type="submit" value="Submit"></center>
</tbody>
</table>

和js代码:

<script>
$('#form-id').change(function() {
    if ($('#pt').attr('checked')) {
        $('#pur').show();
        $('#gf').show();
        $('#lw').show();
        $('#bt1').show();
    } else {
        $('#pur').hide();
        $('#gf').hide();
        $('#lw').hide();
        $('#bt1').hide();
    }
    if ($('#gt').attr('checked')) {
        $('#pur').show();
        $('#kb').show();
        $('#b').show();
        $('#kkb').show();
        $('#bf').show();
        $('#ch').show();
        $('#t6').show();
        $('#t7').show();
        $('#t8').show();
        $('#t9').show();
    } else {
        $('#pur1').hide();
        $('#kb').hide();
        $('#b').hide();
        $('#kkb').hide();
        $('#bf').hide();
        $('#ch').hide();
        $('#t6').hide();
        $('#t7').hide();
        $('#t8').hide();
        $('#t9').hide();
    }
    if ($('#bt').attr('checked')) {
        $('#pur').show();
        $('#gf').show();
        $('#lw').show();
        $('#bt1').show();
    } else {
        $('#pur2').hide();
        $('#gf1').hide();
        $('#lw1').hide();
        $('#bt12').hide();
    }
});
</script>

我找到了很多脚本,但这是我使用 wordpress 主题的唯一一个。

感谢所有帮助!

【问题讨论】:

  • 这到底是个什么样的地球哈哈 :))) 你不能先重构你的代码吗?
  • 控制台有什么错误??
  • 不是什么“不起作用”,但您可以尝试is(':checked'),但我投票结束,因为没有明确问题陈述的问题对其他读者没有用处。
  • 我是 stockoverflow 的新手,用的不多。不明白它是如何在这里工作的。但是,当您按下 readio 按钮时,脚本会工作,下一个单选按钮会显示出来。在所有浏览器上都可以,但在我的安卓手机上的互联网浏览器上不行?

标签: javascript jquery wordpress mobile browser


【解决方案1】:

如果您在 Android 设备上使用 Chrome 浏览器,您应该会获得与桌面版本相同的结果。尝试其他设备、浏览器,看看是否有同样的问题。

【讨论】:

    猜你喜欢
    • 2012-05-16
    • 2012-08-13
    • 2015-12-17
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多