javascript - 如何使用 JQuery 动态显示 div 标签?
问题描述
我的代码有什么问题?它没有显示我的期望。这就是我的代码的样子:
$(document).ready(function(){
...
$('input[name=hdr_approval]').change(function(){
if($('input:radio[name=hdr_approval]')[0].checked == true){
$('#stage-action').css('display', 'block');
}else{
$('#stage-action').css('display', 'none');
}
});
if($('input[name=hdr_approval]:checked').length > 0 || $('#stage').val() === 'Personal Qualification Data'){
$('#stage-action').css('display', 'block');
console.log(document.getElementById("stage").value);
}else{
$('#stage-action').css('display', 'none');
}
console.log(document.getElementById("stage-action").style.display);
...
});
这是我的页面的一部分:
<div class="col s6 m6 l6 body-reset">
<div class="right-align col s11 body-reset" style="height: inherit !important;">
<p id="stage-text" class="custom-stage-text" style="height: inherit !important; top: 0px !important; padding-top: 0px; margin-top: 0px; ">
@switch($application->stage)
@case('Credential Review')
{{ 'Personal Qualification Data' }}
@break
@case('Personal Qualification Data')
{{ 'Proceed to Qualifying Exam' }}
@break
@endswitch
</p>
</div>
<div class="right-align col s1">
<button type="submit" id="stage-action" name="action_submit" form="lt-edit-form" class="btn-flats box"><i class="fas fa-chevron-circle-right"></i></button>
</div>
</div>
默认情况下,我的stage-action
显示设置为无。
我的日志正在输出应该做的事情,但我不知道为什么stage-action
没有显示在我的页面上。
解决方案
推荐阅读
- c# - NHibernate Join Query 只有一个 QueryOver 实例并且没有定义映射关系
- conditional - 液体:我如何结合两个条件?
- powershell - 如何在 Powershell 中更改 PSCustomObject 数组
- reactjs - 在 Typescript 项目中实现 react-router PrivateRoute
- python - 使用 pymatlab 从 Python 脚本调用 Matlab 函数
- python - 字典更新序列元素 #0 错误
- node.js - 无法理解异步/等待
- python - Google Cloud Dataflow Python SDK 更新
- c# - 嵌套列表和 Automapper.Map
- r - 在 Data.Table 中保留标签列时的行子集