[英]How to get the inner text of a span tag of the current DIV
I have multiple product divs, like the following :我有多个产品div,如下所示:
<div class="special" id="special">
<a href="patinete-12v.html" class="special-link">
<p class="special-img">
<img src="img/vehicules/patinetes/25.png" alt="">
</p>
<h3><span id="pdctName">Patinete Crazy Eléctrico 12v</span></h3>
</a>
<p class="special-info">
<span class="ribbon2 animated swing infinite">
<span>Oferta!</span>
</span>
<a href="#" class="special-categ">Ofertas especiales</a>
<span class="special-price">200,00 €</span>
<del style="margin-top: -9px;">250,00 €</del>
<a href="0#" class="special-add cd-add-to-cart js-cd-add-to-cart">+ Añadir a la cesta</a>
</p>
</div>
I need to get the inner text of the spans elements( <span class="special-price">
and <span id="pdctName">
).我需要获取<span class="special-price">
元素的内部文本( <span class="special-price">
和<span id="pdctName">
)。
i tried this var pdctName = document.getElementById("special").querySelectorAll("span#pdctName");
我试过这个var pdctName = document.getElementById("special").querySelectorAll("span#pdctName");
but it gives me the value of the first divsion, and i actually want the value of the current div.但是它给了我第一次除法的值,而我实际上想要的是当前div的值。
I have multiple product divs, like the following :我有多个产品div,如下所示:
<div class="special" id="special">
<a href="patinete-12v.html" class="special-link">
<p class="special-img">
<img src="img/vehicules/patinetes/25.png" alt="">
</p>
<h3><span id="pdctName">Patinete Crazy Eléctrico 12v</span></h3>
</a>
<p class="special-info">
<span class="ribbon2 animated swing infinite">
<span>Oferta!</span>
</span>
<a href="#" class="special-categ">Ofertas especiales</a>
<span class="special-price">200,00 €</span>
<del style="margin-top: -9px;">250,00 €</del>
<a href="0#" class="special-add cd-add-to-cart js-cd-add-to-cart">+ Añadir a la cesta</a>
</p>
</div>
I need to get the inner text of the spans elements( <span class="special-price">
and <span id="pdctName">
).我需要获取<span class="special-price">
元素的内部文本( <span class="special-price">
和<span id="pdctName">
)。
i tried this var pdctName = document.getElementById("special").querySelectorAll("span#pdctName");
我试过这个var pdctName = document.getElementById("special").querySelectorAll("span#pdctName");
but it gives me the value of the first divsion, and i actually want the value of the current div.但是它给了我第一次除法的值,而我实际上想要的是当前div的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.