javascript - How to apply Onitem click using Java script -


below html page:

<body>  <div data-role="page" id="taxmanhomepage"  data-theme="e">     <div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme="e">         <h4 align="center">taxmann demo app</h4>     </div>     <div data-role="content" data-theme="e">         <a data-role="button" onclick="callservice()">webservice</a>          todays headlines:         <div class="content-primary">             <ul id="newlist" data-role="listview"  data-inset="true" data-filter-theme="e" data-divider-theme="e"></ul>         </div>     </div> </div> </body> 

and java script code:

var url="http://www.taxmann.com/taxmannwhatsnewservice/mobileservice.aspx?service=corporatelaws"; var news_id=null; var news_title=null; var news_short_description=null; var new_hash = {}; document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() {  }  function backtohome() {     $.mobile.changepage('#taxmanhomepage', {         reverse : false,         changehash : false     }); }  $(document).on('pagebeforeshow','#newslistpage',function(event){      $('#newlist').empty();     });  function callservice(){      $.ajax({         type : "get",         url : url,         datatype : "json",         cache : false,         error : function(xhr, ajaxoptions, thrownerror) {             debugger;         },          success : function(response, status, xhr) {             response=xhr.responsetext;              var responsearray = json.parse(response);             console.log(responsearray);             var length = responsearray.length;             var html='';             for(i=0;i<length;i++)             {                 news_id=$.trim(responsearray[i].news_id);                 news_title=$.trim(responsearray[i].news_title);                 news_short_description=$.trim(responsearray[i].news_short_description);                 new_hash[news_id]=[news_title,news_short_description];                 $("#newlist").append("<li 'style='font-size:10pt';'font-weight:bold';'><a href='#' ><h1 class='myheader'>"+news_title+"</h1><br><h6 class='myheader'>"+news_short_description+"</h6></a></li>");             }             $("#newlist").append("</ul>");             $('#newlist').listview('refresh');          }      }); } 

i able display in listview have apply on item click mean , dsiplay particular item id in alert mean if clcik on first item should display first item id if click in second or 3rd.....then should display id. how new in java script


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -