Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 2.27 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Accessing Instance variables of javascript objects
  2. <!doctype html>
  3. <html>
  4. <head>
  5.   <title>jQuery Tagit Demo Page (HTML)</title>
  6.   <script src="demo/js/jquery.1.7.2.min.js"></script>
  7.   <script src="demo/js/jquery-ui.1.8.20.min.js"></script>
  8.   <script src="js/tagit.js"></script>
  9.  
  10.   <link href="demo/css/demo.css" rel="stylesheet" type="text/css"/>
  11.   <link rel="stylesheet" type="text/css" href="css/tagit-stylish-yellow.css">
  12.  
  13.   <script>
  14.  
  15.  
  16.     $(document).ready(function () {
  17.  
  18.  
  19.     var list = new Array();
  20.      var availableTags = [];
  21.  
  22.      $('#demo2').tagit({tagSource:availableTags});
  23.  
  24.  
  25.      $('#demo2GetTags').click(function () {
  26.         showTags($('#demo2').tagit('tags'))
  27.       });
  28.  
  29.      /*
  30.     $('li[data-value]').each(function(){
  31.         alert($(this).data("value"));
  32.     });*/
  33.  
  34.     function showTags(tags) {
  35.  
  36.         var list = new Array();
  37.         console.log(tags);
  38.         var string;
  39.         for (var i in tags)
  40.           string +=    new String(tags[i].value)
  41.  
  42.             console.log(string);
  43.         }
  44.  
  45.  
  46.     });
  47.   </script>
  48. </head>
  49. <body>
  50.  
  51. <div id="wrap">
  52.  
  53. <div class="box">
  54.   <div class="note">
  55.     You can manually specify tags in your markup by adding <em>list items</em> to the unordered list!
  56.   </div>
  57.  
  58.     <ul id="demo2" data-name="demo2">
  59.         <li data-value="here">here</li>
  60.         <li data-value="are">are</li>
  61.         <li data-value="some...">some</li>
  62.         <!-- notice that this tag is setting a different value :) -->
  63.         <li data-value="initial">initial</li>
  64.         <li data-value="tags">tags</li>
  65.     </ul>
  66.  
  67.   <div class="buttons">
  68.     <button id="demo2GetTags" value="Get Tags">Get Tags</button>
  69.     <button id="demo2ResetTags" value="Reset Tags">Reset Tags</button>
  70.     <button id="view-tags">View Tags on the console </button>
  71.   </div>
  72. </div>
  73.  
  74. </div>
  75. <script>
  76. </script>
  77. </body>
  78. </html>
  79.        
  80. function showTags(tags) {
  81.  
  82.             var list = new Array();
  83.             console.log(tags);
  84.             var string;
  85.             for (var i in tags)
  86.               string +=  tags[i].value;
  87.                 console.log(string);
  88.             }
  89.         });
  90.        
  91. function showTags(tags) {
  92.  
  93.         var list = new Array();
  94.         console.log(tags);
  95.  
  96.         for (var i in tags)
  97.           string +=  tags[i].value;
  98.  
  99.             console.log(string);
  100.         }
  101.  
  102.  
  103.     });
  104.        
  105. var string = "";