Click here to Skip to main content
15,894,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to save data from table to database so using jquery, and html attributes to get the table values and i am differentiating new and old data on table from adding a attribute on tr(table row) that is data_histry="new" or data_histry="old"

when i saving then jquery cannot get this attribute from table attribute..


please help

What I have tried:

adding data in table

var markup = "<tr id='tab" + tabid + "' class='test old' style='background-color:#E9E9E9;' data_type='test' data_histry='old'><td class='data-name' medi-id='"+ data[i].tid +"'>" + data[i].name + "</td><td class='data-dis'>" + data[i].descript + "</td><td><button test-id='" + data[i].id + "' type='button' class='btn btn-danger table-delete'>"></button></td></tr>";

$("#table-body").append(markup); 


and want to get property from attribute by the process from loop

console.log($('#tab'+i).attr('data_histry'));

where #tab is id of tr and i is counting variable

and on console its giving me

undefined
Posted
Comments
ZurdoDev 1-Nov-17 8:59am    
Do some basic troubleshooting. So, first make sure that $('#tab'+i).length is > 0.
Also, view the html source in your browser and make sure all is as you expect it to be.
Naveen Roy 3-Nov-17 1:44am    
thanks sir... for giving time...
F-ES Sitecore 1-Nov-17 9:13am    
The code works ok for me, check the html in the browser tools to ensure that valid html has been added to the table.
Naveen Roy 3-Nov-17 1:45am    
thanks a lot to check it on your browser. Thanks for giving time...
Karthik_Mahalingam 1-Nov-17 23:43pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900