do something if element hidden
This question already has an answer here:
try something like this
if($('#testElement').is(':visible')){
//what you want to do when is visible
}
for your code
if($('input[name="firstname"], input[name="lastname"]').is(':visible')){
$('input[name="fullname"]').hide();
}
REFERENCE
http://api.jquery.com/visible-selector/
you should change
<input type="text" name="fullname">
to
<input type="hidden" name="fullname">
to make an input field hidden
这应该工作$(element).is(":visible")
上一篇: 如何检查一个元素是否隐藏了jquery
下一篇: 如果元素隐藏,做些事情