How to show time in front of web service data in jquery mobile

北战南征 提交于 2020-01-24 20:58:12

问题


![enter image description here][1] Hi I am getting server data from web socket but i am facing one problem that i need to show current time in the from to front of web service data as show ..I am able to show data but time is not in front of that..:(

How to show time in front of data.

I am using like this

function nativePluginResultHandler (result)
{
      $('#realTimeContents' ).append('<p>'+result+'</p>');

}

!


回答1:


From this answer: How to get current time in jquery mobile or jquery

Why wouldn't taking your server's appended results and then prepending with the javascript time stamp work?

  $('#time').prepend("<b>" + hours + ":" + minutes + " " + "</b>");



回答2:


Try something like this:

function date() {
    var now = new Date(),
        now = now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();
    $('#time').html(now);
}

Fiddle: http://jsfiddle.net/u32pU/2/



来源:https://stackoverflow.com/questions/17881261/how-to-show-time-in-front-of-web-service-data-in-jquery-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!