Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 585167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:58:29+00:00 2026-05-13T14:58:29+00:00

I have been working in a JavaScript file and my content has been working

  • 0

I have been working in a JavaScript file and my content has been working with phrases. Now I want to change the style of those phrases. The first function (see function swapFE) I want to change the font style of the phrase node to normal. And change the color of the phrase node to the color value (155, 102, 102). The second function (see swapEF) I want to change the font style to italic and the font color to black. How do I write these? And do I write it within my those functions in JavaScript or do style changes get applied directly within CSS or HTML?

These are the two functions I want to apply the style changes to:

    //this function changes the French phrase to an English phrase.
function swapFE(e) {
       var phrase = e.srcElement; 
       //phrase.innerText = english[phrase.id];
    var parent = phrase.parentNode;
    //childNodes[0] is the number of the phrase +1 
    var idnum = parent.childNodes[0];
    //parseInt takes a textstring and extracts it to make a number. Then you will subtract 1 from the number.
    var phrasenum = parseInt(idnum.innerHTML)-1;
    phrase.innerText = english[phrasenum];

  }


function swapEF(e) {
       var phrase = e.srcElement; 
       //phrase.innerText = english[phrase.id];
    var parent = phrase.parentNode;
    var idnum = parent.childNodes[0];
    var phrasenum = parseInt(idnum.innerHTML)-1;
    phrase.innerText = french[phrasenum];

If you could even just point me to a reference where I can find these properties that’d be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:58:29+00:00Added an answer on May 13, 2026 at 2:58 pm

    I figured out how to add the style changes. By writing parent.childNodes[1].style.fontStyle= “normal” or “italic” (depending on the function); and parent.childNodes[1].style.color = “black”.

    //this function changes the French phrase to an English phrase.
        function swapFE(e) {
               var phrase = e.srcElement; 
               //phrase.innerText = english[phrase.id];
               var parent = phrase.parentNode;
               //childNodes[0] is the number of the phrase +1 
               var idnum = parent.childNodes[0];
               //parseInt takes a textstring and extracts it to make a number. Then you will subtract 1 from the number.
    
           var phrasenum = parseInt(idnum.innerHTML)-1;
           phrase.innerText = english[phrasenum];
           parent.childNodes[1].style.fontStyle= "normal";
             //Below is the correct way to write an RGB style.
             parent.childNodes[1].style.color = "rgb(155, 102, 102)";
    }
    
    
    function swapEF(e) {
           var phrase = e.srcElement; 
           //phrase.innerText = english[phrase.id];
           var parent = phrase.parentNode;
           var idnum = parent.childNodes[0];
           var phrasenum = parseInt(idnum.innerHTML)-1;
           phrase.innerText = french[phrasenum];
           parent.childNodes[1].style.fontStyle= "italic";
           parent.childNodes[1].style.color= "black";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a project that dynamically creates a javascript file using
I have been working on this JavaScript file so that as someone types in
So I have been working with javascript for a website I am designing, shocker
I have been working on facebook application and you know on facebook native javascript
I have been working with Zend for a few months now and am at
I have been working on a small file manager module in a project where
So I'm working with django and file uploads and I need a javascript function
I have been working on a template using almost all jquery/javascript. Mostly I am
Have been working on this question for a couple hours and have come close
I have been working with SQL Server as a Developer a while. One thing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.