html5-data

store and retrieve javascript arrays into and from HTML5 data attributes

僤鯓⒐⒋嵵緔 提交于 2019-11-28 17:44:07
How can a javascript Array be stored in an HTML5 data attribute? I've tried every variation of JSON.stringify cation and escaping characters. What is the precise method to store the array and retrieve it again? note I build the array with [ $("#firstSelectedElement").val(), $("#secondSelectedElement").val() ] . I retrieve id="storageElement" data-storeIt="stuff" with $("#storageElement").data('storeit') . I can never seem to retrieve the data as a true Array , only an Array of characters. iurii It turned out that you could use the html escaped characters in the element data attribute to have

store and retrieve javascript arrays into and from HTML5 data attributes

家住魔仙堡 提交于 2019-11-27 10:39:30
问题 How can a javascript Array be stored in an HTML5 data attribute? I've tried every variation of JSON.stringify cation and escaping characters. What is the precise method to store the array and retrieve it again? note I build the array with [ $("#firstSelectedElement").val(), $("#secondSelectedElement").val() ] . I retrieve id="storageElement" data-storeIt="stuff" with $("#storageElement").data('storeit') . I can never seem to retrieve the data as a true Array , only an Array of characters. 回答1

Are empty HTML5 data attributes valid?

元气小坏坏 提交于 2019-11-26 16:06:58
I'd like to write a simple jQuery plugin that displays inline modals under specified elements. My idea is for the script to auto-init based on data attributes specified on elements. A very basic example: <p data-modal-target>Hover over me for an inline modal!</p> <div data-modal-content data-modal-align="right" data-modal-trigger="hover" data-modal-offset="10px"><!-- any desired syntax can go here --></div> I'm just wondering if data-modal-target in the above example is valid, or does it have to be data-modal-target="true" ? I don't care about anything crappier than IE9 etc, my only

Are empty HTML5 data attributes valid?

♀尐吖头ヾ 提交于 2019-11-26 04:43:02
问题 I\'d like to write a simple jQuery plugin that displays inline modals under specified elements. My idea is for the script to auto-init based on data attributes specified on elements. A very basic example: <p data-modal-target>Hover over me for an inline modal!</p> <div data-modal-content data-modal-align=\"right\" data-modal-trigger=\"hover\" data-modal-offset=\"10px\"><!-- any desired syntax can go here --></div> I\'m just wondering if data-modal-target in the above example is valid, or does