I have two links in my html code. I use both of them to read the data element using jQuery. However it works fine for one of them and for the other it returns undefined values.
the html is as follows
<a class="loadCustomerInfo" href="#Augustinho" date-customerid="1" date-customername="Augustinho" date-customeraddress="mercado shoprite" date-companyname="Auto Kilimanjaro" date-phoneone="828759460" date-city="0">Augustinho</a>
the following jQuery I use
$(".loadCustomerInfo").live('click',function(){
//alert("add item");
var idVar=$(this).data('customerid');
// alert($(this).innerHTML);
alert($(this).attr('data-customername'));
alert($(this).data('customername'));
var randid = new Date().getUTCMilliseconds();
$("#customerInfoTable").append('<tr><th id="customerInfoTH" colspan=2>Customer Information</th></tr>' +
'<tr><th>Customer Name</th> <td>' +$(this).data('customername')+ '</td></tr>' +
'<tr><th>Company Name</th><td>' +$(this).data('companyname')+ '</td></tr>' +
'<tr><th>Address</th><td>' +$(this).data('customeraddress')+ '</td></tr>' +
'<tr><th>City</th><td>' +$(this).data('city')+ '</td></tr>' +
'<tr><th>Primary Phone</th><td>' +$(this).data('phoneone')+ '</td></tr>');
//return false;
});
The click function is working as I get the response from alert() but always undefined, also in my html it displays undefined for all variables.
data-notdate-4) use window.console&&console.log instead of alert.oninstead of.live, and please check the names, as you got different attribute names in js than in html.date!=data.