Concentrate on a specific component within an overlay using jQuery

How can I focus on a specific area within an overlay when adding an item to the cart? I want to make the rest of the overlay darker and the targeted area more visible.

See a quick mockup here: https://i.sstatic.net/UpJuc.png

Here's the HTML code:

<div class="cm-notification-content cm-notification-content-extended notification-content-extended  cm-auto-hide" data-ca-notification-key="3b71ec814b1cb78f78b7b6602c6258a6" style="top: 143.5px;"><h1>Congrats. You've just added to Cart ...<span class="cm-notification-close close"></span></h1><div class="notification-body-extended"><div class="ty-product-notification__body cm-notification-max-height" style="max-height: 367px;">

            <div class="ty-product-notification__item clearfix">
                <img class="ty-pict  ty-product-notification__image  " src="http://aus2015.ambientlounge.com/images/thumbnails/100/100/detailed/2/wildberry.jpg?t=1440337739" alt="" title="">
                <div class="ty-product-notification__content clearfix butterfly-sofa-bean-bags">
                    <a href="http://aus2015.ambientlounge.com/interior/gold-class-bean-bags/acoustic-sofa-bean-bags/wildberry-deluxe.html" class="ty-product-notification__product-name">Wildberry Deluxe</a>
                                            <div class="ty-product-notification__price">
                                                            <span class="none">1</span>&nbsp;x&nbsp;<span class="none">$</span><span id="sec_price_2343099257" class="none">269.00</span>
                                                    </div>
                                                        </div>
            </div>


<form action="search_postcode.php" method="post" class="postcode_locator_form" name="postcode_locator_form">
    <div class="ty-control-group">
        <label for="postcode_locator_search" class="ty-control-group__title">Check we can send you filling (metro only)</label>
        <div class="ty-input-append ty-m-none">
            <input type="text" size="20" class="ty-input-text" id="postcode_locator_search" name="postcode_locator_search" value="" placeholder="Enter postcode">
            <button title="Search" class="ty-btn-go" type="submit">Go!</button>
<input type="hidden" name="dispatch" value="postcode_locator.search">
        </div>

    </div>
</form>

...

    </div><div class="ty-product-notification__buttons clearfix">    <div class="ty-float-left">

    <a href="http://aus2015.ambientlounge.com/index.php?dispatch=checkout.cart" class="ty-btn ty-btn__secondary ">View my Cart</a>

    </div>
            <div class="ty-float-right">

    <a href="http://aus2015.ambientlounge.com/index.php?dispatch=checkout.checkout" class="ty-btn ty-btn__primary ">Pay Now</a>

        </div>
    </div></div></div>

Answer №1

When you display the overlay, just run this code:

$("#postcode_locator_search").focus();

Tested a Prototype

$(function () {
  $("#btn").click(function () {
    $("body").prepend('<div class="mask"></div>');
    $("li:nth-child(2)").addClass("check").find("input").focus();
  });
});
* {margin: 0; padding: 0; list-style: none; font-family: 'Segoe UI';}
li {margin: 0 0 10px;}
.mask {position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 1; background-color: rgba(0,0,0,0.5);}
li.check {position: relative; z-index: 2; background-color: #fff;}
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<form action="">
  <ul>
    <li>
      <label>
        <strong>Input 1</strong>
        <input type="text" name="" />
      </label>
    </li>
    <li>
      <label>
        <strong>Input 2</strong>
        <input type="text" name="" />
      </label>
    </li>
    <li>
      <label>
        <strong>Input 3</strong>
        <input type="text" name="" />
      </label>
    </li>
    <li>
      <label>
        <strong>Input 4</strong>
        <input type="text" name="" />
      </label>
    </li>
    <li>
      <label>
        <strong>Input 5</strong>
        <input type="text" name="" />
      </label>
    </li>
  </ul>
</form>
<input type="button" value="Click Me!" id="btn">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Mysql Joins with parameterized queries in Node.js: A Comprehensive Guide

Currently, I am utilizing Node.js and Express.js for my project. In particular, I am incorporating the "mysql2 library" into my development process. My current task involves concatenating and joining queries with parameters in a secure manner. How can I ...

In JavaScript, use a regular expression to replace all instances of %2F with %

Looking for a JavaScript/regex solution to transform %2F into %21. This will allow me to successfully pass forward slashes through a GET parameter after using encodeURIComponent() on a URL. Once the data reaches the server, I'll convert back from ! ...

Animating a JQuery Slider using code from scratch

I'm attempting to dynamically alter/animate a JQuery slider. In this scenario, there are two arrays present: one for the values that need to be modified and another for the durations between modifications. By monitoring the console, you'll observ ...

Dynamic background rectangle tilted at a 45-degree angle overlays an image

I have a challenge to create a 45-degree rotated square inside a square container, making sure it is responsive. Here's the code I have come up with so far: <div class="container"> <figure> <img src="https://placekitten.com/500 ...

Discover the secret to instantly displaying comments after submission without refreshing the page in VueJS

Is there a way to display the comment instantly after clicking on the submit button, without having to refresh the page? Currently, the comment is saved to the database but only appears after refreshing. I'm looking for a solution or syntax that can h ...

Executing jQuery when the DOM is loaded in Angularjs

Seeking assistance with integrating jQuery into AngularJS for a project. I am relatively new to AngularJS and experiencing difficulty in firing jQuery on Dom Ready. Despite various attempts, the code does not seem to work as expected. I am currently using ...

Tips for adjusting the size of iframe content to fit its div area in Bootstrap 4 when the window is minimized

I recently started building a website and encountered an issue with resizing the window to fit an iframe containing a video within a div. I'm unsure where exactly in the CSS code I need to make adjustments for this. Can someone help me out? The websi ...

Is it possible to display a title tooltip only when the CSS ellipsis feature is active in a React component?

Issue: I am trying to find a neat solution to display a title tooltip on items that have a CSS ellipsis applied, within a React component. Approaches Attempted: I created a ref, but it only exists after componentDidUpdate. Therefore, I force an update w ...

Each occurrence of a variable update will result in the storing of its value within an

I'm struggling to include a variable in an array without it changing. Every time I try to push the variable to the array, it seems to alter. i = 10; function addToArray() { let b = []; b.push(i); console.log(b); } addToArray(); The variable n ...

Unraveling the mysteries of webpack configuration

import * as webpack from 'webpack'; ... transforms.webpackConfiguration = (config: webpack.Configuration) => { patchWebpackConfig(config, options); While reviewing code within an Angular project, I came across the snippet above. One part ...

Obtain Phonegap Build CLI-5.2.0 and Close Directly from a Web Application

Struggling with integrating window open calls in my app using inappbrowser. Essentially, I am utilizing phonegap to wrap a mobile skinned CMS site with special app functionalities. Here is the snippet from index.html where I am deploying inappbrowser (wit ...

Show User Input as a dynamic tool-tip in Highcharts

Is it possible to gather 12 user inputs through multiple text areas in a popup dialog box, and then use these inputs as tooltips for various points on a graph like the one shown in this demo: http://www.highcharts.com/demo/line-labels? I haven't found ...

Arrange components with minimal spacing

I am currently working on a design that requires a perfectly aligned table using divs. Here is what I have done so far: My goal is to have the time section placed on the left side of the entire row, while keeping the text right-aligned to avoid creating a ...

Utilizing Selenium IDE and XPath to confirm that a checkbox is selected only when the associated label contains certain text

I need assistance in creating an Xpath query to validate if a specific checkbox is checked within the nested divs of the panel-body div. My goal is to ensure that a checkbox with the label "Evaluations" contains the class "checked". Below is the snippet of ...

Utilize an array of JSON objects to populate an array of interfaces in Angular/Typescript

I am currently facing a dilemma - my code is functioning without any errors when executed, but my text editor is flagging an issue stating that the property 'categories' does not exist on type 'CategoryInterface[]' (specifically on the ...

Error encountered while testing karma: subscription function is not recognized

I encountered an issue with my karma unit test failing with the following error message. "this.gridApi.getScaleWidth().subscribe is not a function" GridApi.ts export class GridApi { private scaleWidthSubject = new BehaviorSubject<{value: number}& ...

Place images within a card container using Bootstrap 4

I'm currently working with Bootstrap 4 and I am utilizing a card div. The card uses display flex and I am having trouble floating images within it, possibly because the card is configured to only allow one image. How can I successfully float multiple ...

What could be causing the mousedown event to go unrecognized in JavaScript when using THREE?

I have a basic THREE.js setup and I am trying to click on a spherical object, however, nothing happens when I click anywhere in the browser. I attempted to follow the advice given in this post but it did not work. The full code is provided below: <!DO ...

Express, the mongoose package delivers a response of an empty array

I have encountered a common issue regarding pluralization with mongoose default model names. Despite trying various solutions, the problem persists as I am getting an empty array as the result. In my local mongoDB database, there are 2 documents in the "us ...

save the received data to a new document

How can I pass the data returned from the API below to another function in a separate JavaScript file? This question may be similar to others, but those do not involve working with returned results. Please consider this before labeling it as a duplicate. ...