jQueryには、特定のテーブルがHTMLドキュメントに存在するかどうかを判断する方法があり、存在するかどうかを判断する方法はalert();
ありますか?
ドキュメントで探している特定のテーブルの存在は次のとおりです。
<table id="main_table"
jQueryには、特定のテーブルがHTMLドキュメントに存在するかどうかを判断する方法があり、存在するかどうかを判断する方法はalert();
ありますか?
ドキュメントで探している特定のテーブルの存在は次のとおりです。
<table id="main_table"
$(function() {
// after dom ready
if($('table#main_table').length){
alert('exists');
}
})
domready
イベントでチェックするだけ
$(function() {
if ($('#main_table').length) { ... /* element exists */ }
/**
* or - without passing again through jQuery function -
* if (document.getElementById('main_table')) { ... }
*/
});
$(document).ready(function() {
$("#check").click(function() {
if($('table#main_table').length){
alert('Table Exists');
}
});
});
</p>