I'm trying to know if the textbox is empty when i change of textbox, how can i do it? i tried to create a script, but i totally failed.
I'm new at jQuery.
Here my js script
$("#description").blur(function())){
if ($("#description").val() == "") alert ("Empty!");
}}
I want to know if my textarea is empty or not
<label>Description</label>
<textarea cols="55" rows="3" id="description" name="description">
</textarea>
<br><br>
What do i need to do? I dont want to call a function inside the textarea
Wrap it in dom ready
$(document).ready(function () {
$("#description").blur(function () {
if ($("#description").val() == "") alert("Empty!");
});
});
aLso your syntax has some mistakes
Use change
$("#description").on('change',function(){
if(this.value == "") alert("Empty");
});
$("#description").blur(function(){
if ($("#description").val() == ""){ alert ("Empty!")};
});
$(document).ready(function () {
if ($('#element').is(':empty')){
//do something
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.