Check if textbox is empty before executing jQuery
3 answers
See below code
<div>
<div>
<input type="text" id="text"/>
<input type="button" value="click" id="click"/>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#click").click(function () {
if ($("#text").val() != '') {
myfunction();
}
});
});
function myfunction() {
alert($("#text").val());
}
</script>
0
source to share