使用JS定位类名称迭代 [英] Targeting class name iterations with JS
问题描述
我试图将JSON数据解析为类名为slide_content的特定迭代
I am trying to parse JSON data into specific iterations of a class name "slide_content"
要获得这样的结果:
slide_content[0]
不提供 getElementByClass()
选择器。
有关的API数据如下:
将直JS转换为JQuery
The API data in question is here: Converting Straight JS to JQuery
干杯!
Myles
Cheers! Myles
推荐答案
使用jQuery。它允许您使用 $('。someClass')
来检索具有给定类名的所有元素。
Use jQuery. It allows you to use $('.someClass')
to retrieve all elements with a given class name.
如果你不能使用jQuery或另一个JS库的某些原因,只需使用Sizzle选择器引擎,也是由jQuery使用 - 它不是很多的代码,所以你甚至可以复制&粘贴到一个项目的JS文件(但不要'这样做,它是丑陋的:p)。但是,因为你标记你的问题与jquery我假设你可以使用jQuery ...
If you cannot use jQuery or another JS library for some reason, simply use the Sizzle selector engine which is also used by jQuery - it's not very much code so you could even copy&paste it into one of your project's JS files (but don't do that, it's ugly :p). But since you tagged your question with jquery I assume you can use jQuery...
这篇关于使用JS定位类名称迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!