Javascript 如何使用JQuery动态显示div标记?
我的代码有什么问题?它没有显示出我的期望。这就是我的代码的样子:Javascript 如何使用JQuery动态显示div标记?,javascript,jquery,Javascript,Jquery,我的代码有什么问题?它没有显示出我的期望。这就是我的代码的样子: $(document).ready(function(){ ... $('input[name=hdr_approval]').change(function(){ if($('input:radio[name=hdr_approval]')[0].checked == true){ $('#stage-action').css('display', 'block'); }else{
$(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)
@案例(“凭证审核”)
{{“个人资格数据”}
@中断
@案例(“个人资格数据”)
{{‘继续资格考试}
@中断
@终端开关
默认情况下,“我的<代码>阶段动作代码>显示”设置为“无”
我的日志输出了应该做的事情,但是我不明白为什么我的页面上没有显示
stage action
。没有相关的HTML,真的很难说!!!我添加了一些代码。@AnirudhLou-你的意思是即使document.getElementById(“stage action”).style.display的控制台日志是block
,元素仍然没有显示在html
?。是的,在我的if语句中,它满足我的日志it输出块上的一个条件。$('input[name=hdr\u approval]:checked')。length>0 | |$('#stage')。val()===='Personal Qualification Data'
-这两个条件都不是真的,因此设置为显示:无代码>(我将您的代码放在这里的一个片段中,看看会发生什么)。如果设置$('#stage action').css('display','block')
而不是none
,然后出现复选框。