use*_*535 1 jquery input document-ready
如何检查所有输入框以查看文档加载时是否有值?
$(document).ready(function(){
var inputVal=$("input").val().trim();
if(inputVal!=''){
}
})
Run Code Online (Sandbox Code Playgroud)
我想对任何有值的输入框执行操作.
这是一种方式:
$('input, select, textarea').each(
function(){
var val = $(this).val().trim();
if (val == ''){
// do stuff with the non-valued element
}
});
Run Code Online (Sandbox Code Playgroud)
在仔细阅读时,似乎OP想要对非空字段做一些事情,所以:
$('input, select, textarea').each(
function(){
var val = $(this).val().trim();
if (val.length){
// do stuff with the valued element
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5355 次 |
| 最近记录: |