Hi MorningZ,

Did not want to use this approach as,  the tables can be added and
removed dynamically..., so to complete the story .. htere are 2
buttons add and delete.
Let say,  the user adds
3 tables first. Then the global variable value will be 3  and tables
will have ID as 'Instructions_1', 'Instructions_2' and
'Instructions_3'.

Now if he selects all table and deletes and adds  4 tables ,  the  ids
will be  'Instructions_4, 'Instructions_5' and 'Instructions_6'.
So can end up with random IDs too . .. if he selects and deletes 4 and
adds 3 more tables.


The solution of  $('table[id=Instructions]')   seems to be working
fine .. though as per People its a kludge :)
Can't see a simpler solution than using duplicate IDs.



Thanks a lot Gurus !

Regards
Samant





On Mar 3, 8:35 am, MorningZ <[EMAIL PROTECTED]> wrote:
> "On click of a button, i
>
> > add tables dynamically (using the 1st table as a template) to the page
> > (using DOM + js).
> > Hence i end up with multiple tables with duplicate id's"
>
> Have a counter of some sort, like a global variable like
>
> var TableCount = 0;
>
> when you add, append this value to the id and increment it for the
> next added table
>
> To select all these tables, it's simply:
>
> $("table[id^='Instructions']")
>
> that would grab all tables that "have an ID that starts with
> instructions"

Reply via email to