Coloring the child of the element












0















I have six sections. Inside them, I am creating a new div with 6 span circles. I made a function that does that and it works fine. Now, I need to color the circle that is the same number as its parent section. For example: if I have the third section from the top, I need the third circle to be colored and the rest not. Same goes for the fourth section and fourth circle.



This would be my HTML with only one section... others are the same.






var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>





The circles are there but the coloring of them is a problem... this way I colored them all... need some help.










share|improve this question

























  • Can you create a fiddle from your code?

    – SilentCoder
    Nov 14 '18 at 9:28






  • 1





    Please edit your question to include a Minimal, Complete, and Verifiable example.

    – Chris G
    Nov 14 '18 at 9:29











  • I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

    – Bojan Kolano
    Nov 14 '18 at 9:32








  • 1





    what is anchor.length ?

    – SilentCoder
    Nov 14 '18 at 9:34






  • 1





    @BojanKolano I have provided with a general solution according to my understanding of your question.

    – SilentCoder
    Nov 14 '18 at 9:46
















0















I have six sections. Inside them, I am creating a new div with 6 span circles. I made a function that does that and it works fine. Now, I need to color the circle that is the same number as its parent section. For example: if I have the third section from the top, I need the third circle to be colored and the rest not. Same goes for the fourth section and fourth circle.



This would be my HTML with only one section... others are the same.






var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>





The circles are there but the coloring of them is a problem... this way I colored them all... need some help.










share|improve this question

























  • Can you create a fiddle from your code?

    – SilentCoder
    Nov 14 '18 at 9:28






  • 1





    Please edit your question to include a Minimal, Complete, and Verifiable example.

    – Chris G
    Nov 14 '18 at 9:29











  • I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

    – Bojan Kolano
    Nov 14 '18 at 9:32








  • 1





    what is anchor.length ?

    – SilentCoder
    Nov 14 '18 at 9:34






  • 1





    @BojanKolano I have provided with a general solution according to my understanding of your question.

    – SilentCoder
    Nov 14 '18 at 9:46














0












0








0








I have six sections. Inside them, I am creating a new div with 6 span circles. I made a function that does that and it works fine. Now, I need to color the circle that is the same number as its parent section. For example: if I have the third section from the top, I need the third circle to be colored and the rest not. Same goes for the fourth section and fourth circle.



This would be my HTML with only one section... others are the same.






var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>





The circles are there but the coloring of them is a problem... this way I colored them all... need some help.










share|improve this question
















I have six sections. Inside them, I am creating a new div with 6 span circles. I made a function that does that and it works fine. Now, I need to color the circle that is the same number as its parent section. For example: if I have the third section from the top, I need the third circle to be colored and the rest not. Same goes for the fourth section and fourth circle.



This would be my HTML with only one section... others are the same.






var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>





The circles are there but the coloring of them is a problem... this way I colored them all... need some help.






var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>





var anchor = $('.anchor-link');
var section = $('.panels');
var count = 0;
if (anchor.length > count) {
section.append('<div class= "circle"></div>');
var circle = $('.circle');
circle.each(function(e){
count++;
circle.append('<span></span>');
})
}

var green = $('.circle > span');
circle.each(function(e){
if ($(this).find('span').length > 0) {
var indexSection = section.index(this);
var indexSpan = green.index(this);
if (indexSection == indexSpan){
green.addClass('greens');
}
}
})

<section class="two-split panels">
<div class="container">
<div class="row">
<div class="col col-2 left-col">
<h4 class="heading grey">Our Strategic Model</h4>
<h2 class="section-title green">Creating value...</h2>
<p class="txt grey">UDG Healthcare is an international outsourcing services group focussed on the healthcare industry. The Group is organised and managed in three separate divisions, each focused on providing a specific area of specialist services to healthcare companies.</p>
<img class="pic pic-left" src="./images/left-white.png" alt="Customers">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey">How we create value</h4>
<p class="text small-text grey">Our strategy is to capitalise on an increasing trend by pharmaceutical, biotech and medtech companies to outsource non-core and specialist activities on an international basis. To achieve this we provide specialist skills and technical capabilities to clients across local and international markets.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading grey padded">What makes us different</h4>
<p class="text small-text grey padded">We strive to create strong market offerings which can provide customers with a range of specialist capabilities within each of our areas of operation. We work in partnership with the manufacturer to create a bespoke solution to best address their objectives. We operate with a quality and governance framework which reflects the industry standards which allows clients to outsource with confidence.</p>
</div>
</div>
</div>
<div class="col col-2 right-col">
<h2 class="section-title white">...Growing sustainably</h2>
<p class="txt white">The strategy of the Group is to focus on maximising Shareholder value from outsourced commercialisation services, by capitalising on its existing market leading positions as the demand for specialist outsourced services in the healthcare sector increases, driving higher levels of growth and profitability. We aim to drive growth through a combination of organic growth supplemented by strategic acquisitions, which will drive increasing returns on capital employed for the Group.</p>
<img src="./images/right-green.png" alt="People" class="pic pic-right">
<div class="row">
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">People at the core</h4>
<p class="text small-text white">Attracting and retaining talented leaders is essential for UDGHealthcare to sustain its growth model.</p>
</div>
<div class="col col-2 col-2-t small">
<h4 class="small-heading white">Delivering value</h4>
<p class="text small-text white">Successful delivery of our strategy will result in increased shareholder value through share price appreciation and dividends. Disciplined financial management and increased cash generation will allow for on-going re-investment in the business to sustain the growth model and capitalise on the opportunity to grow our services.</p>
</div>
</div>
</div>
</div>
<div class="bottom-btn">
<a href="javascript:;" class="download-link">
<span class="s s-down-arrow btn-link">
<span class="hide">download</span>
</span>Download Strategic Model <span class="no-under">(PDF, 185KB)</span>
</a>
<a href="#" class="going-down anchor-link">
<button type="button" class="down down-desktop">
<img src="./images/down-green.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</a>
<button type="button" class="down down-tablet">
<img src="./images/down.png" alt="Move to the top content">
<span class="s s-down-arrow btn-arrow">
<span class="hide">Move Up</span>
</span>
</button>
</div>
</div>
</section>






javascript jquery html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 10:04









GYaN

2,10731431




2,10731431










asked Nov 14 '18 at 9:21









Bojan KolanoBojan Kolano

13510




13510













  • Can you create a fiddle from your code?

    – SilentCoder
    Nov 14 '18 at 9:28






  • 1





    Please edit your question to include a Minimal, Complete, and Verifiable example.

    – Chris G
    Nov 14 '18 at 9:29











  • I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

    – Bojan Kolano
    Nov 14 '18 at 9:32








  • 1





    what is anchor.length ?

    – SilentCoder
    Nov 14 '18 at 9:34






  • 1





    @BojanKolano I have provided with a general solution according to my understanding of your question.

    – SilentCoder
    Nov 14 '18 at 9:46



















  • Can you create a fiddle from your code?

    – SilentCoder
    Nov 14 '18 at 9:28






  • 1





    Please edit your question to include a Minimal, Complete, and Verifiable example.

    – Chris G
    Nov 14 '18 at 9:29











  • I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

    – Bojan Kolano
    Nov 14 '18 at 9:32








  • 1





    what is anchor.length ?

    – SilentCoder
    Nov 14 '18 at 9:34






  • 1





    @BojanKolano I have provided with a general solution according to my understanding of your question.

    – SilentCoder
    Nov 14 '18 at 9:46

















Can you create a fiddle from your code?

– SilentCoder
Nov 14 '18 at 9:28





Can you create a fiddle from your code?

– SilentCoder
Nov 14 '18 at 9:28




1




1





Please edit your question to include a Minimal, Complete, and Verifiable example.

– Chris G
Nov 14 '18 at 9:29





Please edit your question to include a Minimal, Complete, and Verifiable example.

– Chris G
Nov 14 '18 at 9:29













I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

– Bojan Kolano
Nov 14 '18 at 9:32







I can't provide a fiddle because im working on internal database ..fiddle won't work. The question is understandable .. I don't know how to make it clearer ... I need to colour the circle which has to match the number of the section ..

– Bojan Kolano
Nov 14 '18 at 9:32






1




1





what is anchor.length ?

– SilentCoder
Nov 14 '18 at 9:34





what is anchor.length ?

– SilentCoder
Nov 14 '18 at 9:34




1




1





@BojanKolano I have provided with a general solution according to my understanding of your question.

– SilentCoder
Nov 14 '18 at 9:46





@BojanKolano I have provided with a general solution according to my understanding of your question.

– SilentCoder
Nov 14 '18 at 9:46












1 Answer
1






active

oldest

votes


















1














Since you HTML code is a little bit messy, I will provide you with a general solution. let me know if this the kind of solution you are looking for?






$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>








share|improve this answer
























  • This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

    – Bojan Kolano
    Nov 14 '18 at 9:53











  • No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

    – SilentCoder
    Nov 14 '18 at 9:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296714%2fcoloring-the-child-of-the-element%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Since you HTML code is a little bit messy, I will provide you with a general solution. let me know if this the kind of solution you are looking for?






$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>








share|improve this answer
























  • This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

    – Bojan Kolano
    Nov 14 '18 at 9:53











  • No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

    – SilentCoder
    Nov 14 '18 at 9:56
















1














Since you HTML code is a little bit messy, I will provide you with a general solution. let me know if this the kind of solution you are looking for?






$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>








share|improve this answer
























  • This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

    – Bojan Kolano
    Nov 14 '18 at 9:53











  • No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

    – SilentCoder
    Nov 14 '18 at 9:56














1












1








1







Since you HTML code is a little bit messy, I will provide you with a general solution. let me know if this the kind of solution you are looking for?






$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>








share|improve this answer













Since you HTML code is a little bit messy, I will provide you with a general solution. let me know if this the kind of solution you are looking for?






$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>








$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>





$(document).ready(function(){
$('section').each(function(idx,ele){
let circles = '';
for(let i = 0; i<6; i++){
circles += '<div class= "circle"></div>';
}
$(ele).append(circles);

$(ele).find('.circle').eq(idx).addClass('green');
});

})

.circle{
width:20px;
height:20px;
border-radius:100%;
background-color:#ccc;
margin:5px;
display:inline-block;
}

.green{
background-color:#ccee11 !important;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>
<section class="two-split panels">
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.</div>
</section>

<section class="two-split panels">
<div>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</div>
</section>

<section class="two-split panels">
<div>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</div>
</section>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 9:44









SilentCoderSilentCoder

1,79011020




1,79011020













  • This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

    – Bojan Kolano
    Nov 14 '18 at 9:53











  • No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

    – SilentCoder
    Nov 14 '18 at 9:56



















  • This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

    – Bojan Kolano
    Nov 14 '18 at 9:53











  • No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

    – SilentCoder
    Nov 14 '18 at 9:56

















This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

– Bojan Kolano
Nov 14 '18 at 9:53





This is what I needed .. I know HTML was not perfect . I can't post everything but man you are a GOD ! Thanks :)

– Bojan Kolano
Nov 14 '18 at 9:53













No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

– SilentCoder
Nov 14 '18 at 9:56





No worries mate. Happy coding. Cheers!! I know that you cannot post everything here. That is why I also gave you a general solution that assuming you have knowledge to map with your solution. :)

– SilentCoder
Nov 14 '18 at 9:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296714%2fcoloring-the-child-of-the-element%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine