我一直在考虑一个任务... “算在字符串中的单词的数量‘tx_val’有3,4,5或6个字符 显示在用逗号分隔的单线这四个数”如何计算Javascript中有3,4,5或6个字符的字符串中的单词数?
我一直在尝试多个不同的循环语句,但我似乎无法得到正确的答案。
这里是我被赋予一起工作的代码:
<html>
<head>
<script language="javascript">
<!--
function fred()
{
var tx_val=document.alice.tx.value;
len_tx=tx_val.length
-->
</script>
</head>
<body>
<form name="alice">
<b>Assignment #1 Javascript</b>
<p>
The text box below is named "tx". The form is named "alice".
<p>
<input type="text" name="tx" formname="alice" size="50" value="the quick brown fox jumped over the lazy dogs back">
</form>
谢谢!! :]我有这么难过,但你的代码工作!对此,我真的非常感激! – Krista 2011-04-26 05:53:29