Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
this.template.querySelector not working salesforce LWC

I have fetched the sumValue ,sumValueColor, from a class to lwc js. and i have to set the sumValueColor to two CSS classes.i have done like the this.

js

@wire(getData, { iId: '$contactId' })
    GetData({data}){
        if (data) {
            this.sumValue= data.sumValue;
          this.template.querySelector('div.sumValueColor1').style.setProperty('--sumValueColor', data.sumValueColor);
            this.template.querySelector('div.sumValueColor2').style.setProperty('--sumValueColor', data.sumValueColor);
      
}
}

css

div.sumValueColor1 {
    color: var(--sumValueColor);
}
div.sumValueColor2 {
    color: var(--sumValueColor);
}

html

<template>
   <template if:true={hasChanges}>
    <div class="slds-grid slds-grid_align-center">
            <div class="primary-num-text-large"  >
            <div class="sumValueColor1" >{sumValue}</div>
            </div>
        </div>
  </template>
 <template if:false={hasChanges}>
    <div class="slds-grid slds-grid_align-center">
            <div class="primary-num-text-medium"  >
            <div class="sumValueColor2" >{sumValue}</div>
            </div>
        </div>
<template>

But this is not working ,the color is not reflecting.how to fix this? can someone help?

Thanks, Serah

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!