2017-02-24 64 views
2

我有数据,当我点击Show More它显示数据和Show More消失。数据和一个新按钮出现。当我点击时,数据再次消失。一旦被点击,我怎样才能让Show More出现?如何使用Jquery使按钮消失然后reapear?

我的HTML代码为:

<button id="show">Show More</button> 
<div id="complete"> 
    <img src="Pictures/xerox.png" height="20%" width="20%"> 
</div> 
<p> 
<button id="hide">Show Less</button> 

我jQuery代码是:

$(document).ready(function(){ 
    $("#show").click(function(){ 
     $(this).parent().addClass("more"); 
     $(this).hide(); 
     $("#complete").show(); 
    }); 

    $("#hide").click(function(){ 
     $("#complete").hide(); 
    }); 
}); 
+0

什么是感谢你,没有工作。 :) –

回答

0

它看起来像你的jQuery告诉对象进行调用来隐藏自身单击时:

$(this).hide(); 

根据您的描述,我建议您将以下内容添加到处理Show Les的函数中S功能:

$('#show').show(); 
0

我从这个问题的理解是你想

<style> 
#complete{ 
display:none; 
} 
#hide{ 
display:none; 
} 
</style> 

<button id="show">Show More</button> 
<div id="complete"> 
<img src="Pictures/xerox.png" height="20%" width="20%"> 
</div> 
<p> 
<button id="hide">Show Less</button> 


<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> 

<script> 
$(document).ready(function(){ 
    $("#show").click(function(){ 
     $(this).parent().addClass("more"); 
     $(this).hide(); 
     $("#hide").show(); 
     $("#complete").show(); 
    }); 

    $("#hide").click(function(){ 
     $("#complete").hide(); 
     $("#show").show(); 
     $("#hide").hide(); 
    }); 
}); 
</script> 
+0

复制并粘贴到浏览器中,你会看到你想要的行为 –