「jQuery」指定要素が存在するかどうか判定する方法
構文
$(selector).length
jQueryコード
$(function () {
$('#cft).on('submit', function (event) {
//class="layoutTable'が存在判定
if($('.layoutTable').length){
console.log('exits');
}else{
console.log('not exist);
}
});
}
$(function () {
$('#cft).on('submit', function (event) {
//class="layoutTable'が存在判定
if($('.layoutTable').length){
console.log('exits');
}else{
console.log('not exist);
}
});
}
$(function () { $('#cft).on('submit', function (event) { //class="layoutTable'が存在判定 if($('.layoutTable').length){ console.log('exits'); }else{ console.log('not exist); } }); }