tags:

views:

191

answers:

5

Hello All:

I am adding custom attributes to my HTMLtags something like

<li customeId="1">

I am to access this custom attribute in IE but in firefox, I am not able to get the values of these attributes. Any suggestion on how to access custom attribute in FireFox or any other way. I am using HTML 4 for development.

Code to access:

  var test =  licollection[index].customeId;

Thanks Ashwani

A: 

Try

var test = licollection[index].getAttribute("customeId");
KennyTM
+1  A: 
test.getAttribute('customerid');

Did you try this?

vsync
+1  A: 

Hopefully below code will be helpful for you.

<div id="navigation">
 <ul>
  <li customeId="1"></li>
  <li customeId="2"></li>
  <li customeId="3"></li>
 </ul>
</div>


var x = document.getElementById('navigation');
if (!x) return;
var liCollections = x.getElementsByTagName('li');
for (var i=0;i<liCollections.length;i++)
   alert(liCollections[i].getAttribute('customerid', 0));

Its clear enough, and you can understand it easily.

GS_Guy
A: 

licollection[index].getAttribute("customeId")

reference: http://www.java2s.com/Code/JavaScriptReference/Javascript-Methods/getAttributeSyntaxParametersandNote.htm

mangokun