Body Close button

I've made a form floating in the middle of the screen

And for that I designed a button to close

But I want be anywhere on the screen with the mouse clicked closed form

my code

  $(".offer-close").click(function () {
<div class="div-fix">
<div class="offer-shop">

    <div class="cur-package">
        <div class="offer-close"><i class="fa fa-times"></i></div>

        <div class="pack-b">

            <div class="pack-price">6500 <div>

            <div class="pack-shop"><a href="#" target="blank">Buy</a></div>
        <div class="pack-c">any ...</div>

For example, form feedback website :

Answers 1

  • Adding below script will solve your problem.

    $(document).mouseup(function (e)
        var container = $(".div-fix");
        if (! // if the target of the click isn't the container...
            && container.has( === 0) // ... nor a descendant of the container

    jsFiddle Demo

Related Articles