doubianxian6557
doubianxian6557
2014-09-19 23:37

如何在jquery中将带有数学运算的字符串声明为变量

  • php
  • html
  • javascript
  • jquery

PHP:

<?php
   $test = "100-12";
?>

jQuery:

var test = <?php echo $test ?>;
alert(test);

in dev tool sources (F12) it looks like this:

var test = 100-12;

but when already alerted / pass the data in other pages or just alerted the value of test becomes 89 which is the value when 100 is subtracted by 12.

i need the as is value which is 100-12 not the subtracted. how do i stop jQuery from subtracting my string.

i tried String() toString() and even "" + but nothing works.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐