Yekver
Yekver

Reputation: 5203

id or class? dilemma

There are several tables, where row id - is the number of records in the database, there is a problem. If there are few tables on the page, the id will be repeated. And it's not good, because jQuery does not work correctly because of dublicate id's. I only have 2 outputs:

  1. Concatenation a first table id's = "a_{num}", second table id's = "b_{num}" and that's on...
  2. Replace the id to class

But I don't like both of them. Maybe there is a normal solution to this problem?

Upvotes: 0

Views: 51

Answers (2)

Karoly Horvath
Karoly Horvath

Reputation: 96326

Maybe you need none of them?

Use a selector for all tables, then filter for the number of rows (or whatever you use for displaying the rows..)

Upvotes: 0

Raynos
Raynos

Reputation: 169551

Option 3. Use HTML5 data- attributes to store meta data.

Then just set it on the table

$("table#someId").data("database-records", number)

Upvotes: 7

Related Questions