Js我很业余,赶紧这种弱类型的语言容易被搞晕。问个可能很撮的问题:<form action="date.jsp" name='login'>
<input name="username" /><br/>
<input name="password" type="password" /><br/>
</form>
<a href="#" name="link1" onclick="javascript: submit()">提交</a>var username = document.login.username.value;
var password = document.login.password.value;这样可以取到表单login里的username/password输入框的值,。var href = document.link1.href.value;为什么这样又不能取到链接link的属性href呢?还有取值时,什么时候要加value,什么时候不要加value啊?

解决方案 »

  1.   

    表单元素才能通过form 获得 。  <input type="text" />
      <input type="checkbox" />
      <input type="radio" />
      <input type="image" />
      <input type="file" />
      <input type="submit" />
      <input type="reset" />
      <input type="password" />
      <input type="button" />
      <select><option/></select>
      <textarea></textarea>
      <button></button>.value 就是获取对象的value属性 。
      

  2.   

    所以说。。 IE害死人。
    标准的写法要 document.getElementsByName("link1")[0]
    IE下在FORM外面  要想直接用   得是ID才行
      

  3.   

    value不过是input的一个属性 和href一样 只不过你能看到input的value属性而已
    所以href是不需要再加.value的
      

  4.   

    怎么比较容易学好Js啊?可能还是因为平时写得比较少,
    导致Js一直掌握得不好。