-4
HTML代码是否有可能得到附加/ HTML功能的值
<div id="price-tag"><i class="fa fa-inr"></i> <span id="price"></span></strong></div>
有附加价值的跨度
$("#price").html(Price);
Java脚本函数现在我想要得到的价格值 - java脚本代码
document.getElementById('price-tag').onclick = function(e){
alert(document.getElementById('price').value);
}
其返回未定义。 有什么方法可以获得价值?
'span'元素没有一个'value'财产,这些都是与用户输入相关的元素。如果你想要元素的内部html,使用'.innerHTML'。如果你只想要文本内容,可以使用'.textContent'。 – nem035
使用'document.getElementById(“price”)。innerHTML' –
如果你使用jQuery,**使用** jQuery。使用'$('#price').val()',而不是'document.getElementById('price').value',尽管在你的情况下你需要'.text()'或'.html()' – j08691