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

  • SEARCH
  • Home
  • 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 537039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:53:05+00:00 2026-05-13T09:53:05+00:00

In order to highlight a certain p element, I’ve written some JS to make

  • 0

In order to highlight a certain p element, I’ve written some JS to make it appear above a darkened background.

In order to do this, I used jQuery to create an overlay, and then clone the information p element and absolutely positioned it over the overlay.

Because it dropped a few CSS properties (not being inherited because of the new position in the page), I used jQuery to add them.

It works almost perfectly. In my Firefox 3.5.6 on Mac OS X, when it fades away, there is a slight disrepencacy of a matter of pixels. I know it’s nitpicking, but I’d love to have it disappear and the end user not know the difference.

The test is available here: https://www.ikatanspa.com/book-online/?test

Here is the jQuery function too

var highlightFormSuccess = function() {

    var fadeTo = 0.6;

    var $info = $('p.information');

    if ($info.length) {


        // make overlay

        var $overlay = $('<div />')
            .css({
                display: 'none',
                width: '100%',
                height: $(document).height(),
                position: 'absolute',
                top: 0,
                left: 0,
                zIndex: 32767,
                opacity: 0
            })
            .attr({
                id: 'overlay'
            })
            .appendTo('body');

        // pull out success block and position above overlay

        var left = $info.position().left,
            top = $info.position().top,
            fontSize = $info.css('font-size'),
            width = $info.width(),
            color = $info.css('color'),
            lineHeight = $info.css('line-height');


        var $newInfo = $info.clone()
                            .css({
                                position: 'absolute',
                                top: top,
                                left: left,
                                'font-size': fontSize,
                                'line-height': lineHeight,
                                width: width,
                                color: color,
                                zIndex: 32767
                            })
                            .appendTo('body');

        $overlay
        .show()
        .fadeTo(1000, fadeTo);
        // wait then fade back out
        setTimeout(function() {

            $($overlay, $newInfo).fadeOut(1000, function() {
                $newInfo.fadeOut(250, function() { $(this).remove(); } );
            });

        }, 2500);


    };


};
  • 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-13T09:53:05+00:00Added an answer on May 13, 2026 at 9:53 am

    Perhaps you can make things a bit easier. I just replicated the desired effect by setting my paragraph rules to:

    p.highlight {
      position:relative;
      background-color:#ffffff;
      z-index:10;
    }
    

    And my overlay to:

    div.overlay {
      position:fixed;
      background-color:#000000;
      z-index:5; // lower than my paragraph, higher than all else
      top:0; left:0; width:100%; height:100%;
    }
    

    —

    <body>
      <div class="overlay"></div>
      <p>I'm a paragraph.</p>
      <p class="highlight">I too am a paragraph.</p>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to get number of order highlighted element (by javascript, jquery): <li>A</li> <li>B</li>
In order to highlight spacing between Chinese characters I've got this code function replaceSpaces(){
I'm trying to use SyntaxHighlighter 3.0.83 on Blogger in order to highlight some simple
In order to indicate activity, some applications (e.g. Pidgin) highlight their entry in GNOME's
My team has come to conclusion that in order to highlight certain text we
In order to achieve spriting by compass according to the documentation I wrote this:
I'm trying to change the background of certain items in a combobox that meet
I have wrote some code in order to add 100 x 100 cells to
I'm trying to create a textarea that will highlight some keywords as the user
I've created some annotations (Underline, Highlight, Strikeout, Squiggly) in Acrobat and am digging out

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.