获取量程文本的值 [英] Get value of Span Text

查看:99
本文介绍了获取量程文本的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跨度 class =span和一个隐藏字段 class =dropdown



span 文本更改,我需要抓取文本并将其设置为隐藏字段值的值。

然后我将使用php(我已经拥有)并使用隐藏字段的名称向我发送文本。



我该怎么做?

 < script type =text / javascript> 
document.getElementById('button1')。onChange = function(){
document.getElementById('hidden_​​field_id')。value = document.getElementById('span_id')。innerHTML;
}
< / script>


I have a span with class="span" and a hidden field class="dropdown".

The span text changes, and I need to grab the text and set it as the value of the hidden field's value.

I will then use php (I already have) and use the name of the hidden field to email me the text.

How do I do it?

解决方案

<script type="text/javascript">
document.getElementById('button1').onChange = function () {
    document.getElementById('hidden_field_id').value = document.getElementById('span_id').innerHTML;
}
</script>

这篇关于获取量程文本的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆