Ahoura Ghotbi Ahoura Ghotbi - 1 year ago 76
HTML Question

jquery get a custom (made up) Attribute value

I have a the following html piece :

<div onClick="javascript:getComments(this);" store-id="143568" class="CountryRow" style="padding: 4px;"><div class="flag flag_az"></div> &nbsp; Azerbaijan</div>

and I would like to create a jquery function to get the value of
. I have the following however its not working :

getComments = function(input) {
fValue = $(input).val( $(input).attr("store-id") );
alert('the ID :'+fValue);

can someone be kind enough to tell me what it is that I am doing wrong.

Answer Source

This works perfectly:

getComments = function(input) {
  fValue =  $(input).attr("store-id");
  alert('the ID :'+fValue);


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download