Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
379 views
in Technique[技术] by (71.8m points)

javascript - jQuery显示隐藏,不显示第二个div(JQuery show hide, not showing second div)

I have a Jquery show hide script that i have been using fine, i now want to add in a second div to show hide..

(我有一个我一直使用很好的Jquery show hide脚本,我现在想添加第二个div来显示hide。)

first div still shows and hides as it should however the second div hides but wont show..

(第一个div仍会显示和隐藏,但是第二个div会隐藏但不会显示。)

code:

(码:)

 $(document).ready(function() { $('.slidingDiv').hide(); $('#show_hide').show(); $('.equipdetailupload').hide(); $('#show_hide2').show(); $('#show_hide').click(function() { $(".slidingDiv").slideToggle(); var isvisible = $(this).next('.slidingDiv').is(':visible'); if (isvisible) { $(this).next('.slidingDiv').hide(); } else { $(this).next('.slidingDiv').show(); } }); $('#show_hide2').click(function() { $(".equipdetailupload").slideToggle(); var isvisible = $(this).next('.equipdetailupload').is(':visible'); if (isvisible) { $(this).next('.equipdetailupload').hide(); } else { $(this).next('.equipdetailupload').show(); } }); }); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a id='show_hide2' href='#'>upload Image</a> <p class='equipdetailupload'></p> <---------------------see notes <div class='equipdetailupload'> <!-- #INCLUDE virtual="imageup/uploadtester1.asp" --> </div> 

Notes: The line marked with see notes i added as a test while trying to get the div to show, with that line in the div also shows without it the code doesnt work

(注意:标记为see的行是我在尝试使div显示时作为测试添加的,div中的该行也显示没有它的代码,该代码不起作用)

  ask by Chris Rowley translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i have got this working now, solution is :-

(我现在有这个工作,解决方案是:-)

<script type="text/javascript">

$(document).ready(function() {

($(document).ready(function(){)

$('.slidingDiv').hide();
$('#show_hide').show();
$('.equipdetailupload').hide();
$('#show_hide2').show();

$('#show_hide').click(function() {

     $(".slidingDiv").slideToggle();
     var isvisible = $(this).next('.slidingDiv').is(':visible');

     if ( isvisible ) {
       $(this).next('.slidingDiv').hide();
     } else{
       $(this).next('.slidingDiv').show();
     }
});


$('#show_hide2').click(function() {

     $(".equipdetailupload").slideToggle();
     var isvisible = $(this).next('.equipdetailupload').is(':visible');

     if ( isvisible ) {
       $(this).next('.equipdetailupload').hide();
     } else{
       $(this).next('.equipdetailupload').show();
     }
});
$('#show_hide3').click(function() {

     $(".equipdetailupload1").slideToggle();
     var isvisible = $(this).next('.equipdetailupload1').is(':visible');

     if ( isvisible ) {
       $(this).next('.equipdetailupload1').hide();
     } else{
       $(this).next('.equipdetailupload1').show();
     }
});

});

(});)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...