[英]jQuery loop through elements with class suffix
I have a class suffix named fadecontent
in a joomla 3.0 website, and i have to loop trough all div's that have this class suffix using the $.each() function. 我在joomla 3.0网站上有一个名为fadecontent
的类后缀,我必须使用$ .each()函数循环使用具有此类后缀的所有div。
I tried this but it seems not to work with class suffixes . 我试过这个,但它似乎不适用于类后缀 。 joomla docs: class suffix joomla docs:类后缀
$('.fadecontent').each(function(i, obj) {
with class suffix i mean this: 类后缀我的意思是:
<div class="class classSuffix">exemple</div>
<!--example in my code-->
<div class="moduletable fadecontent">content</div>
How to archieve this? 如何实现这一目标?
EDIT: the script is in the <HEAD>
tag 编辑:脚本位于<HEAD>
标记中
I'm not sure I understand what you mean by class suffixes. 我不确定我理解你的后缀是什么意思。 in your example 在你的例子中
<div class="moduletable fadecontent">content</div>
That div has both the class moduletable and fadecontent. 该div具有类moduletable和fadecontent。 So this should loop through all the divs with the class fadecontent 所以这应该循环遍历所有具有类fadecontent的div
$('.fadecontent').each(function() { console.log('Do Something here'); });
If this doesn't achieve what you're looking for, can you post more of your code so we might be able to see any other errors? 如果这不能达到你想要的,你可以发布更多的代码,以便我们可以看到任何其他错误吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.