On page1 if 2 rows selected, i will get id1, id2
If page2 selected id1 and id2 should be cleared, only page2 selected rows should be there.
How should i achieve this using jquery?
If I understand your question clearly you have selected two rows from the table and you are showing some data related to that data in a <div> or subpages now you want to clear that data when navigated to the new page.
If I have understood it correctly, you can uncheck selected rows using the checkbox in jQuery like
$('.SelectedCheckboxes').prop('checked', false); // uncheck all selected rows which has class SelectedCheckboxes
Now when you get second-page data using jQuery inject in <div>, selected specific row data using
$('.SelectedCheckboxes',"#div2").prop('checked', true); // Checks it //here div2 is id of HTML <div> where new page data is inserted
OR if you can get New Id's of rows using jQuery Ajax
$('#Id1NewPage',"#div2").prop('checked', true); $('#Id2NewPage',"#div2").prop('checked', true);
Considering, you are creating a table with a checkbox as first row in table
<tr> <td><input type="checkbox" id="#Id1NewPage" /></td> <td>..... ....</td> </tr> <tr> <td><input type="checkbox" id="#Id2NewPage" /></td> <td>..... ....</td> </tr>
Hope it helps, thanks
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly