jquery - how to get an html object[data value ] from an array of same html element object -


how data object html object has more 1 element in array.

<div id='show_box'>     <h6 id="#0" data-choosed="1000">1000</h6>     <h6 id="#1" data-choosed="1000">2000</h6>     <h6 id="#2" data-choosed="1000">3000</h6> </div>  

in javascript var h6_len=$("#show_box > h6").length;

         switch (h6_len) {             case 0:                  choosed=$('#show_box > #' + h6_len).data('choosed');                  $('#total_box').text(choosed);// return drop-down clicked               //this part of code working fine.. when case == 0               break;         case 1:               var h6_1=$('#show_box > h6')[0];                   var h6_2=$('#show_box > h6')[1];                    /* having issues... getting data value 1 of array h6 element...                    console.log( typeof h6_1);                   break;             case 2:                   console.log(h6_len);                   break;                   default:                   $('#total_box').empty();           } 

html

<div id='show_box'>     <h6 id="#0" data-choosed="1000">1000</h6>     <h6 id="#1" data-choosed="2000">2000</h6>     <h6 id="#2" data-choosed="3000">3000</h6> </div> 

jquery

$('h6').each(function () {     console.log($(this).data('choosed')); }); 

working fiddle. helps.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -