js为元素赋值的问题 <input type="hidden" id="maxCount" name="maxCount"/>有这样一个元素,想要用JS为其添加值“最大数:20”,然后20的颜色是不一样的,刚学js不知道能不能实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sorry,那里是错的,是text,打错了 是这样吗?颜色的话只能设置整个字符串的颜色,不能设置字符串的一部分的颜色。<html><head><title>test</title></head><body><input type="text" id="maxCount" name="maxCount" /><script type="text/javascript">var maxCount = document.getElementById('maxCount');maxCount.value = '最大数:20';maxCount.style.color = "#F00";</script></body></html> 这个不行,不过你可以把“最大数”几个字放到外面去或者用其他标签来实现啊,比如这样:<html><head><title>test</title></head><body><label for="maxCount">最大数:</label><input type="text" id="maxCount" name="maxCount" /><script type="text/javascript">var maxCount = document.getElementById('maxCount');maxCount.value = '20';maxCount.style.color = "#F00";</script></body></html> 求教如何解除JS脚本对文件的占用? 求助Web开发高手:请为我指明方向 HTML DOM和XML DOM有什么区别? 请大侠帮忙加一个事件! 急!!!有一问题需要帮忙 高分,怎么控制下拉菜单列表的高度? 菜鸟的简单问题,请大家帮忙,马上结帖 javascript简单问题 问下,在JS中可以访问本页面的JSP变量吗?急!! 如何把数据加在到指定列的末尾? 用javascript设置表格中行的位置 js怎样得到table单元格中输入框对象
<html>
<head>
<title>test</title>
</head><body>
<input type="text" id="maxCount" name="maxCount" />
<script type="text/javascript">
var maxCount = document.getElementById('maxCount');
maxCount.value = '最大数:20';
maxCount.style.color = "#F00";
</script>
</body>
</html>
<html>
<head>
<title>test</title>
</head><body>
<label for="maxCount">最大数:</label>
<input type="text" id="maxCount" name="maxCount" />
<script type="text/javascript">
var maxCount = document.getElementById('maxCount');
maxCount.value = '20';
maxCount.style.color = "#F00";
</script>
</body>
</html>