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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:52:33+00:00 2026-05-24T22:52:33+00:00

I have a function that displays a hidden div for error messaging in a

  • 0

I have a function that displays a hidden div for error messaging in a form.

For this function, I need the div to display in 2 different spots depending on the scenario. So I need to add a class if a specific submit button is clicked. I could write a separate function, but I would like to include it within my current function that handles the display of the div:

function giftAlert(){
    var args = arguments;
    if(args.length > 1) {
        // check that custom alert was called with at least two arguments
        var msg = args[0];
        $('.errorPopup').hide();
      $('.couponPopup').hide();
      $('.promotionPopup').hide();
    $("*").removeClass("alertRed");
        $("*").removeClass("CO_form_alert");


        var div = $(".giftPopup");
        div.css({"display":"block"});
        if (div.length == 0) {
            div = $("<div class='giftPopup' onclick='$(this).hide();'></div>");
            $("body").prepend(div);
        }
       div.html(msg);
        for(var i = 1; i < args.length; i++) {
            var inputID = args[i];
           $("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
       $('#' + inputID).focus();
       $('#' + inputID).keydown(function() { $('.giftPopup').hide(); }).change(function() { $('.giftPopup').hide(); }).blur(function() { $('.giftPopup').hide(); });

        }
     }

}

So where this bit is:

var div = $(".giftPopup");
            div.css({"display":"block"});

I would like to add some logic, if input1 is clicked then giftPopup gets an additional class, but only for input1.

help?

  • 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-24T22:52:34+00:00Added an answer on May 24, 2026 at 10:52 pm

    Assuming your input1 element is made up of the html <input class="input1" type=button />, all you need to do in jQuery is:

    $('.input1').click(function(){
        $('.giftPopup').addClass('whatever');
    });
    

    Example: http://jsfiddle.net/ebiewener/Dsb8X/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a JS function that displays a widget at the bottom of
I have a javascript function that toggles the display for rows in a table.
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have this JQuery function: $(document).ready(function() { $(div.descript_long).each(function() { var descript_length = $(div.descript_long).text().length; if(descript_length
I've created a compose note button that when clicked displays an initially hidden div
I have a function that calls a #notify div. When a user clicks on
I want to use jQuery's fadeToggle() function. I have a hidden div and when
I have a JavaScript class that displays a partially-opaque div over top of the
I have a script that displays one div at a time while hiding the
So I have function that formats a date to coerce to given enum DateType{CURRENT,

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.