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.
I tried this but it seems not to work with class suffixes . joomla docs: class suffix
$('.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
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. So this should loop through all the divs with the class fadecontent
$('.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?
If you use JQuery's special selectors such as this:
$('[class$="yoursuffix"]')
It should return elements whose classes contain your suffix pattern. You can read more about this here
链接地址: http://www.djcxy.com/p/83516.html上一篇: 如何为具有多个项目的类设置属性值
下一篇: jQuery通过具有类后缀的元素循环