简体   繁体   English

如何在 HTML 标签中获取内部值

[英]How do I get inner value in HTML tag

I have a variable T我有一个变量 T

T = < input type="text" name="amount" value="3" class="txt-spin" /> T = < input type="text" name="amount" value="3" class="txt-spin" />

Question : How do I get "3" in this tag using javascript ..?问题:如何使用 javascript .. 在此标签中获得“3”?

There is something wrong in the way you're associating the HTML element to a JS Variable.将 HTML 元素关联到 JS 变量的方式有问题。

BUT

If you are using js for this: you can use .getAttribute() Link如果您为此使用 js:您可以使用.getAttribute()链接

Useful: How to work with HTML elements in JS有用:如何在 JS 中使用 HTML 元素

T = document.getElementByClassName("txt-spin").value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM