【发布时间】:2015-11-26 18:44:35
【问题描述】:
我有一个脚本,显示一些并隐藏一些 html,但我不知道如何在显示时添加所需的标签,我已经尝试在我想要的部分中添加属性,但即使在未显示...有人可以帮助我吗?提前致谢!
<div class="start"><select name="start" class="form-control">
<option value="0" class="select">Select City</option>
<?php foreach($rows as $row): ?>
<option <? echo 'value="'.$row['id'].'"';
echo ($row['id'] == $job['start'])?' selected>':'>';
echo $row['name']; ?></option>
<?php endforeach; ?>
</select></div><br />
<br />
<script>
$('select[name=start]').change(function () {
if ($(this).val() == '89') {
$('#otherStart').show();
} else {
$('#otherStart').hide();
}
});
</script>
<br />
<div id="otherStart">
<input type="text" name="otherStart" placeholder="Other City" <? echo ($job['otherStart'])?' value="'.$job['otherStart'].'"':'';
?> class="form-control" >
</div>
【问题讨论】:
-
required属性?将它添加到什么元素以及何时添加?$('#otherStart').show().attr("required", "required");。你应该用jquerybtw 标记你的问题,因为你正在使用它。
标签: javascript php html required