JSFiddle - React, Tailwind, and code Playground
HTML
<div id="b_news">
<form method="post" action="">
</div>
<div class="breaking_news_content">
<div class="container">
<form method="post" action="">
<div class="row">
<div class="form-group">
<textarea id="breaking_news_text" class="breaking_news_text" rows="6" cols="50" placeholder="Add text here..." required></textarea>
</div>
</div>
<div class="row" style="margin-top:20px;">
<input type="submit" class=" save_breaking_news" value="Save Changes"/>
<input type="submit" value="Cancel" class=" breaking_news_cancel">
</div>
</form>
</div>
</div>
</form>
</div>
JavaScript
$(function(){
$(".save_breaking_news").click(function(){
var textcontent = $('.breaking_news_text').val();
if(textcontent == '')
{
alert("Enter Some Text...");
$('.breaking_news_text').focus();
}
else
{
$.ajax({
type: "POST",
url: "index.php",
data:
{
textcontent:textcontent
},
success:function(response)
{
alert('breaking news successfully updated');
}
});
}
return false;
});
});