Untitled


SUBMITTED BY: Guest

DATE: Dec. 11, 2013, 6:11 a.m.

FORMAT: Text only

SIZE: 694 Bytes

HITS: 785

  1. <input type="text" data-setup='{ "method" : "checkbox" }'>
  2. var a = document.querySelectorAll('[data-setup]')
  3. for (var i=0;i<a.length;i++) {
  4. alert(a[i].getAttribute('data-setup'));
  5. }
  6. ALERT: { "method" : "checkbox" }
  7. for (var i=0;i<a.length;i++) {
  8. var obj = JSON.parse(a[i].getAttribute('data-psswrd'));
  9. alert(obj.method); //will alert what was in the method property
  10. console.log(obj); // should log a proper object
  11. }
  12. var myJSON = JSON.parse( a[i].getAttribute('data-psswrd') );
  13. alert( myJSON );

comments powered by Disqus