2016-02-26 80 views
0

所以,我淡出元素具有与点击()后不工作:淡入()的点击()淡出()

$(".newpost-area, .bar-publish").click(function() { //All of this works 
    $(".function-background").fadeIn(700); 
    $(".posttypes").show(); 
}); 

但是,再点击一下,事情发生后,我隐藏元素:

$(".ptyper-postbtn").click(function() { 
    //some ajax stuff here 

    $(".function-background").fadeOut(700, function() { //Everything here works too 
     $(".posttypes").hide(); 
     $(".p-typer").hide(); 
     $(".ptyper-posttitle").html(""); 
     $(".ptyper-postcontent").html(""); 
     $(".hash-tag-input").text(""); 
     typerPosition(); 
    }); 
}); 

但之后,.newpost-area和.bar-publish上的第一个click()事件不再有效。即使我尝试使用来自Chromium的开发人员工具修改.function-background元素的CSS,并将显示屏设置为“阻止”,它也会回到“无”值。

HTML:

从元素,这并不表明:

<div class="function-background"> 
 
    <div class="posttypes"> 
 
    <div class="p-type p-discussion"><i class="fa fa-comments"></i> 
 
     <div class="ptype-text ptext-discussion">Discussão</div> 
 
    </div> 
 
    <div class="p-type p-galery"><i class="fa fa-picture-o"></i> 
 
     <div class="ptype-text ptext-galery">Imagem</div> 
 
    </div> 
 
    <div class="p-type p-list"><i class="fa fa-columns"></i> 
 
     <div class="ptype-text ptext-list">Lista</div> 
 
    </div> 
 
    </div> 
 
    <div class="p-typer"> 
 
    <div class="topic-body"> 
 
     <div class="post-header"> 
 
     <div class="poster-avatar"> 
 
      <img src="http://i.imgur.com/rATFfDM.jpg" class="ptyper-avatar"> 
 
     </div> 
 
     <div class="poster-info"> 
 
      <div class="ptyper-user post-user"><a>Sonic_BR</a> 
 
      </div> 
 
      <div class="ptyper-timeinfo">Publicando uma <b>Discussão</b> no canal <b>Livre</b> 
 
      </div> 
 
      <div class="post-typeicon"> 
 
      <img src="http://dl.dropboxusercontent.com/u/5859176/dybb/images/text.png" alt="Tópico" title="Tópico"> 
 
      </div> 
 
     </div> 
 
     </div> 
 
     <div class="post-content"> 
 
     <div contenteditable="true" class="ptyper-posttitle feedpost-posttitle">Minha publicação</div> 
 
     <ul class="addcontent-options"> 
 
      <li class="addcontent-opt addcontent-image"><i class="fa fa-picture-o"></i> 
 
      </li> 
 
      <li class="addcontent-opt addcontent-video"><i class="fa fa-video-camera"></i> 
 
      </li> 
 
     </ul> 
 
     <div class="typer-addcontent"><i class="fa fa-plus-circle"></i> 
 
     </div> 
 
     <div class="ptyper-postcontent tfeedpost-postcontent medium-editor-placeholder" contenteditable="true" spellcheck="true" data-medium-editor-element="true" role="textbox" aria-multiline="true" medium-editor-index="0" data-placeholder="Escreva algo..."></div> 
 
     <input class="ptyper-posttags" style="display: none;"> 
 
     <div contenteditable="true" class="hash-tag-input" id="hash-tag-input-1">Inserir hashtags...</div> 
 
     <div class="ptyper-options"> 
 
      <div class="ptyper-clearbtn btn btn-large btn-cancel"><i class="fa fa-trash-o"></i>Limpar</div> 
 
      <div class="ptyper-cancelbtn btn btn-large btn-cancel"><i class="fa fa-times"></i>Cancelar</div> 
 
      <div class="ptyper-postbtn btn btn-large btn-confirm"><i class="fa fa-pencil"></i>Publicar</div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

使用Click事件之一:

<div class="newpost-area"><i class="fa fa-pencil-square nparea-icon"></i> 
 
    <div class="nparea-text">Publicar</div> 
 
</div>

+0

您可以添加HTML吗? –

+0

@itsgoingdown完成。 –

回答

1

你已经使用JavaScript删除了大量的HTML,你怎么能显示它呢?

尝试使用下面的代码,它会工作

$(".newpost-area, .bar-publish").click(function() { //All of this works 
    $(".function-background").fadeIn(700); 
    //$(".function-background").show(); 
}); 

$(".ptyper-postbtn").click(function() { 
    //some ajax stuff here 

    $(".function-background").fadeOut(700, function() { //Everything here works too 
     //$(".posttypes").hide(); 
     //$(".p-typer").hide(); 
     //$(".ptyper-posttitle").html(""); 
     //$(".ptyper-postcontent").html(""); 
     //$(".hash-tag-input").text("");   
    }); 
}); 

的问题是与你:

$(".posttypes").hide(); 
$(".p-typer").hide(); 
$(".ptyper-posttitle").html(""); 
$(".ptyper-postcontent").html(""); 
$(".hash-tag-input").text(""); 
+0

我刚修好了!问题是,“$(”。function-background“)。fadeOut()”回调中的所有内容都以某种方式多次运行。我只是把所有东西放在回调里面,现在它可以正常工作..感谢您的帮助! –