如何更改超时功能以关闭点击?

时间:2015-12-22 05:55:56

标签: php jquery

我有一个自动隐藏邮件的代码,

setTimeout(function () {
document.getElementById('err').style.display = 'none';
}, 5000);       

我需要修改此代码,这样当我点击一个按钮时,它会在点击时关闭。

以下是div的HTML代码:

<div class='alert alert-warning alert-dismissible' role='alert'>
  <button type='button' class='close' data-dismiss='alert'
  aria-label='Close'><span aria-hidden='true'>&times;</span></button>
  <h4 id=err>Mail not sent</h4>
</div>

2 个答案:

答案 0 :(得分:1)

你必须这样做

-(void)playSpotifyTrack:(NSURL*)playURI trackDuration:(float)duration {

    id sessionData = [[NSUserDefaults standardUserDefaults] objectForKey:@"SpotifyOAuthSession"];
    self.spotifySession = sessionData ? [NSKeyedUnarchiver unarchiveObjectWithData:sessionData] : nil;

    [self.spotifyPlayer loginWithSession:self.spotifySession callback:^(NSError *error) {
        if (error != nil) {
            NSLog(@"*** Logging in got error: %@", error);
            return;
        }

        [self.spotifyPlayer playURIs:@[ playURI ] fromIndex:0 callback:^(NSError *error) {
            if (error != nil) {
                NSLog(@"*** Starting playback got error: %@", error);
                return;
            }
        }];
    }];

    [self startSeekBar:duration];

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}

调用警报的绑定$('.alert .close').click(function(){ $('.alert-dismissible').fadeOut(); }); 事件和click警报fadeout

答案 1 :(得分:0)

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script  type="text/javascript">
$(document).ready(function(){
    $('.close').click(function(){
        $('.alert-dismissible').fadeOut();
    });
});
</script>