Getting the values of textboxes in Javascript

前端 未结 6 1868
梦谈多话
梦谈多话 2021-01-25 03:41

I have this html code:

Song:
6条回答
  •  鱼传尺愫
    2021-01-25 04:04

    The tagName that is relevant here is "input", not td. That will get you what you're looking for.

    It's almost a cliche on StackOverflow, but I suggest you take a look at JQuery. JQuery allows you to treat your html as a database and query it to get this kind of stuff. If your markup was like this:

    
    

    You could get the value like this:

    $("#id").value();
    

    If you wanted to get the value of the maxlength attribute on it, you could do this:

    $("#id").attr("maxlength");
    

    Much more fun than digging through element arrays.

提交回复
热议问题