我有一个以下的HTML代码
<dl>
<dt><label>test</label></dt>
<dd><input id="someid" type="checkbox" onchange="opConfig.reloadPrice()" class="product-custom-option"></dd>
<dt><label>test</label></dt>
<dd><input id="someid" type="checkbox" onchange="opConfig.reloadPrice()" class="product-custom-option"></dd>
<dt><label>test</label></dt>
<dd><input id="someid" type="checkbox" onchange="opConfig.reloadPrice()" class="product-custom-option"></dd>
<dt><label>test</label></dt>
<dd><input id="someid" type="checkbox" onchange="opConfig.reloadPrice()" class="product-custom-option"></dd>
</dl>
<script>
reloadPrice : function() {
var config = this.config;
var skipIds = [];
$$('body .product-custom-option').each(function(element){
//todo
});
</script>
我想在循环中获取dt-&gt;标签元素文本。在我的原型函数中运行函数名称'reloadprice'。在变更事件上运行。如何使用原型获取标签文本。 任何帮助将不胜感激。
答案 0 :(得分:0)
Prototype扩展DOM
,所以试试这个:
$$('.product-custom-option').each(function(element){
//element return DOM node which is extended by prototype
console.log(element.up().previous().down().innerHTML);
});
我创建了jsfiddle,一切正常。