您好,我使用这个 PHP 脚本 http://www.stevedawson.com/scripts/text-counter.php
为了让它出现在我的 html 页面上,我使用了这个 ajax 脚本。
<script>
$.ajax({
type:'GET',
url:'http://www.solariserat.se/count.php',
data:'',
success: function(data){
$('#container').html(data);
}
});
</script>
加上这段html代码
<div id="container">
<?php include "count.php"; ?>
</div>
它工作得很好,它在 div 中显示计数的数字。
但我希望它显示为输入标签内的值 这可能吗?我该怎么做?
我知道这是错误的,但你明白我的意思 =)
<input value="count.php">
最佳答案
这应该有效:
<input value="<?php include "count.php"; ?>">
然而,更简洁的方法是在呈现 <input>
的 PHP 页面中包含计数值。所以你可以这样做:
<input value="<?= count ?>">
关于javascript - 输入字段的 PHP 计数器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27532017/