This question has been asked before, but most of the answers revolve around HTML5.
My DOCTYPE is:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I need to attach data (phone dialling code) to option values of a select:
<select id="id_creditCardCountry"> <option value="ax">Aland Islands - AX</option> <option value="al">Albania - AL</option> <option value="dz">Algeria - DZ</option><!--e.g. Attach dial code "(+213)" --> <option value="as">American Samoa - AS</option> <option value="ad">Andorra - AD</option> <option value="ai">Anguilla - AI</option> etc There seem to be numerous ways to accomplish this. I need to find the best one (by best I mean most cross browser and efficient).
- The jQuery "data" function http://docs.jquery.com/Core/data -- if this is the best method, can anyone give guidance of how to use in this instance?
- Set data based on element ID - This involves having to give an id to every option in the select.
- Further suggestions?