Ich habe diese Tabellenstruktur.Abrufen der Spalten-ID in einer Tabelle mit jQuery
<table id = "table1">
<thead>
<tr id = "header_row">
<th> <a id = "a1">ABC</a> </th>
<th> <a id = "a2">DEF</a> </th>
<th> <a id = "a3">GHI</a> </th>
<th> <a id = "a4">JKL</a> </th>
</tr>
</thead>
<tr>.....data filling up the table.....</tr>
<tr>.............</tr>
.
.
</table>
So aus dieser Tabelle, möchte ich den Wert „a2“ holen, Können Sie mir bitte sagen, wie dies zu tun? Vielen Dank!
EDIT: Es gibt viele andere <a>
<table>
Tags auf der Seite, also wenn es eine Möglichkeit gibt, mit der ID zu extrahieren?
'$ ('a'). Auf ('Klick', function (e) {e. preventDefault(); alert (this.id);}) ' – Rayon
@RayonDabre Aber das würde mit anderen' ' Tags in der Seite in Konflikt geraten, und können Sie es ohne 'onclick' machen? – Anusha
Das war nur ein Hinweis ... '$ ('table # table1 a'). On ('Klick', Funktion (e) {e.preventDefault(); alert (this.id);})' wird mehr sein Spezifisch! – Rayon