Marquee text with close button using jquery

In this post i will tell you how to create close button in marquee text with the help of jquery and html. You can manually closing flash news section using jquery below javascript code is used to enable the close button in marquee div.

<script>
$(document).ready(function(c) {
$('.alert-close').on('click', function(c){
$('.message').fadeOut('slow', function(c){
$('.message').remove();
});
});
});
</script>

This types of flash news section most of the website now using to display the emergency flash news section dynamically using some technology. This types of marquee text with close button is one of the user friendly because when user don't want that message simple they close the section so none of the  flash news text will disturb the customers. Below i given full code and also i given demo link below you just check it out how it is working and also i given the download button download the code and use it, I hope this simple example is really helpful.



Code for Flash news with close button

<html>
<head>
<title>manually closing flash news section </title>
<style>
.alert {
background-color: #f39c12 !important;

}

.message {
border-radius: 2px;
display: block;
font-size: 10pt;
font-weight: bold;
margin: 0 0 15px;
padding: 10px 10px 10px 35px;
position: relative;
vertical-align: middle;
color: white;
}
.alert-close {

border-radius: 50%;
background-color: #F7C575;
color: #000;
opacity: .6;
cursor: pointer;
font-size: 18px;
font-weight: normal;
height: 22px;
line-height: 21px;
position: absolute;
right: 11px;
text-align: center;
top: 9px;
-webkit-transition: color 0.2s ease-in-out;
-moz-transition: color 0.2s ease-in-out;
-o-transition: color 0.2s ease-in-out;
transition: color 0.2s ease-in-out;
width: 22px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(c) {
$('.alert-close').on('click', function(c){
$('.message').fadeOut('slow', function(c){
$('.message').remove();
});
});
});
</script>
</head>
<body>
<div class="message alert"><marquee style="width:75%;">Flash News: This is manually closing flash news section jquery flash news. You can close this div by clicking the close button. </marquee>
<div class="alert-close"> x </div>
</div>
</body>
</html>

Post a Comment

0 Comments