doumi9618 2015-11-10 16:53
浏览 7
已采纳

如何在php中获取Jquery值[关闭]

I want to grab the return Gameresult value in php which came with the Jquery id call

The html tag

<p id="gameresult">

</p>

i want to grab the value into php which will be appended here

the Jquerypart :

this.enter = function() {
        var obj = g;
        g.platform.soundManager.gameover.play();
        var result = $('<ul><li>You type '+g.score.score+' characters in '+g.time.time+' seconds.</li><li><u>Your speed</u> : about ' + Math.floor( (Math.ceil(g.score.score / 5) / g.time.time) * 60) +' words per minutes!</li></ul>');
        g.platform.stopAnim();
        this.hideMenu();
        $('#gameresult').append(result);
        this.showState(this.screen);

below is the link:

bubbletyping.base.pk

just play the game at the top left corner for demo..

  • 写回答

1条回答 默认 最新

  • douye9822 2015-11-10 17:35
    关注

    Remove the $() stuff around your result string. Also, you should check to make sure g.time.time isn't zero before division.

    var speed = (g.time.time === 0 ? 0 : Math.floor( (Math.ceil(g.score.score / 5) / g.time.time) * 60))
    var result = '<ul><li>You type '+g.score.score+' characters in '+g.time.time+' seconds.</li><li><u>Your speed</u> : about ' + speed +' words per minutes!</li></ul>;
    

    Here is a JS Fiddle demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊