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 8475273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:50:57+00:00 2026-06-10T17:50:57+00:00

I have the current issue: I define via CSS the current role for a

  • 0

I have the current issue: I define via CSS the current role for a div element

.divElement:before {
    background-image: url(../images/triangle.png);
    background-repeat: no-repeat;
    content: "";
    height: 20px;
    left: 62%;
    margin: 0 0 0 -50px;
    position: absolute;
    top: -20px;
    width: 100px;
}

.divElement{
    background: none repeat scroll 0 0 #FFF8D6;
    border-radius: 10px 10px 10px 10px;
    color: black;
    font: 1em/1.4 Cambria,Georgia,sans-serif;
    margin: 0px 500px 3em;    
    padding: 15px;
    position: relative;
    text-align: center;
}

I created this element dynamically using jQuery: $('<div class="divElement"><p><strong></strong></p></div>').appendTo(....) this works correctly. The issue becomes when using jQuery and I try to dynamically change the backgroung-image and the top attribute of the content before the divElement (which I define in CSS with :before)

I tried something like this for the background-image, but doesn’t work:

$('.divElement:before').css('background-image', 'url(../images/triangle_reverse.png)');

How can I do that? Thank to all !!!

  • 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-06-10T17:50:58+00:00Added an answer on June 10, 2026 at 5:50 pm

    I think your best solution is to keep the styling in the CSS for this one (as in this answer) and simply use the addClass function in jQuery. Here’s an example:

    .divElement:before {
        background-image: url(../images/triangle.png);
    }
    
    .divElement.reverse:before {
        background-image: url(../images/triangle_reverse.png);
    }
    

    Then in jQuery all you need to is add the class reverse like this:

    $('.divElement').addClass("reverse");
    

    You can even easily toggle between on and off states using:

    $('.divElement').toggleClass("reverse");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The current issue im facing is comes from the following scenario. I have a
I have the strangest issue. I have a script that calculates what the current
I have the current bundle reference working locally: Bundles.Reference(/Content/global.css); On the development site, this
I have my current location fixed via CoreLocation. Now I want to get those
I have current a developed app which I am going to submit in just
We have this current database which we need to replace some tables by anther
I have the current time format returned from the web service: 2012-06-25T23:45:52.664Z I want
I have the current powershell script $release = read-host enter release $fullPath = 10.0.0.3
I have the current PHP: $thisarray[] = #000; SetProfileField('usercss', $USER->id, implode(',',$thisarray)); Which writes #000
I have three current thoughts on how to do this: re-implement AuthenticationService, which uses

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.