我想检查特定的id元素是否存在。对于前。 id =“ tbvAccountProc:frmFinancingDocumentProcess:btnSave”在这里,我想检查btnSave是否存在。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.process_text_main);
CharSequence text = getIntent()
.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
// process the text
}
和
if ($('#btnSave').length) {
}
和
if ($('#btnSave').length > 0) {
}
和
if ($('#frmFinancingDocumentProcess').length) {
}
尝试了这些,但是视图中存在btnSave,但是它们没有按我预期的那样工作。
如果我检查btnSave是否存在,它必须为return alert('true')否则为false。
HTML:
if (document.getElementById('btnSave')) {
}