Ho una domanda riguardante il controllo dello string
.Rileva se una stringa contiene una tabella
Il string
è da un ckeditor
così l'utente può inserire qualsiasi cosa.
Il nome variable
è htmlData
ed è come:
test here<br />
<table border="1" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td>
111</td>
<td>
222</td>
</tr>
<tr>
<td>
333</td>
<td>
444</td>
</tr>
<tr>
<td>
555</td>
<td>
666</td>
</tr>
</tbody>
</table>
<br />
second test
voglio rilevare se l'utente aggiungere una struttura table
e ho cercato
if(htmlData.indexOf('</table>').length > -1){
console.log('table detected')
}
ma non mostra nulla in il mio console
. Qualcuno può dare un suggerimento su questo?
Grazie mille!
Dio ... cosa sto pensando .... tutto +1 – FlyingCat
si può avere ancora più breve se '(~ htmlData.indexOf ('')) {...} ' – oleq