如何使用JavaScript检查textarea中的某些行是否为空?

<script type="text/javascript" src="../../../js/jquery-1.3.2.min.js"></script>
<script>
$(document).bind('keydown',function (e) {

if(e.which==13) {
function isRowEmpty( idOfTextArea , row ){

  return $("#" + idOfTextArea )[0].value.split("\n")[row-1] == "";

}
alert(isRowEmpty("txtarr",3));

    }
});
</script>
<textarea id="txtarr" rows="30" ></textarea>


但是它总是返回false

最佳答案

//Assumes you use jQuery or equivalent
function isRowEmpty( idOfTextArea , row ){

  return $("#" + idOfTextArea )[0].value.split("\n")[row-1] == "";

}

09-27 00:31