jQuery addClass example
Change class name on click in jQuery
by saidulu401
HTML
<div id="banner-message">
<p class="configurations-button">Hello World</p>
<button>Change color</button>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#banner-message {
background: #fff;
border-radius: 4px;
padding: 20px;
font-size: 25px;
text-align: center;
transition: all 0.2s;
margin: 0 auto;
width: 500px;
}
button {
background: #0084ff;
border: none;
border-radius: 5px;
padding: 8px 14px;
font-size: 15px;
color: #fff;
}
#banner-message.alt {
background: #0084ff;
color: #fff;
margin-top: 40px;
width: 200px;
}
#banner-message.alt button {
background: #fff;
color: #000;
}
JavaScript
var minSpecs = '<h1>Minimum Tech Specs</h1><p>8th generation intel core i5 Processor</p><p>Windows10 Home Edition</p><p>Intel HD Graphics</p><p>8GB RAM</p><p>120GB ROM</p>';
$(".configurations-button").before(minSpecs);
var price = '<div style="display:flex"><div style="flex:1">Standard Delevery</div><div style="flex:1">Free</div></div><div style="display:flex"><div style="flex:1">Dell Price</div><div style="flex:1">$1,009.99</div></div>';
$(".configurations-button").before(price);
var rewards = '<div><img src="star-image.png">Upto 60% back</div><p style="font-size:10px;color:blue">in rewards</div>';
$(".configurations-button").before(rewards);