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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:37:39+00:00 2026-06-14T05:37:39+00:00

I have a textarea that I have a blur event attached to. I don’t

  • 0

I have a textarea that I have a blur event attached to. I don’t want the blur event to run if the user clicks on a specific span.dontClick on the page. However if the user clicks on anything other than the span.dontClick I do want the blur event to run. I have found a way to do this, but it looks awful, feels very hackey, and I’m guessing there is a better solution out there. Here’s what I’ve come up with:

if (event.type === 'focusout') {
  if (
    typeof event.originalEvent !== 'undefined' &&
    typeof event.originalEvent.currentTarget !== 'undefined' &&
    typeof event.originalEvent.currentTarget.activeElement !== 'undefined' &&
    typeof event.originalEvent.currentTarget.activeElement.className !== 'undefined' &&
    event.originalEvent.currentTarget.activeElement.className === 'dontClick'
  ) {
    // abort the code for the blur event (in effect, do nothing)
  }
  else {
    // run code for when a user blurs by not clicking on span
  }

It should probably be noted that the event object is from a jQuery event handler. I’m not sure if it is different or the same as the native event objects.

It should also be noted that this fails silently for most browsers but I get a debug window in IE if I don’t specify the ‘undefined’ state for each object all the way down the line…

If anyone has a more elegant solution I would really appreciate seeing it. Thanks!

  • 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-14T05:37:40+00:00Added an answer on June 14, 2026 at 5:37 am

    You don’t need comparisons to undefined. Just do a truthy test. Also the test for the className isn’t needed. The === comparison will cover it.

     if (
        event.originalEvent &&
        event.originalEvent.currentTarget &&
        event.originalEvent.currentTarget.activeElement &&
        event.originalEvent.currentTarget.activeElement.className === 'dontClick'
      ) {
    

    but then you’re doing more work than needed anyway since jQuery gives you a reliable currentTarget.

     if (
        event.currentTarget.activeElement &&
        event.currentTarget.activeElement.className === 'dontClick'
      ) {
    

    or if you’re in a handler, just use this.

     if (this.activeElement && this.activeElement.className === 'dontClick') {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textarea tag that has text I want a user to edit.
I have a textarea that I might want to disable in certain conditions. I
I have a textarea that I want to fill up the entire screen. Everyway
I have a TextArea that allows user input. I also have TextInput that the
I have a textarea that I want to add a simple wysiwyg editor. I
I have a textarea that is being dynamically reloaded as user input is being
I have a textarea that I want to paste different text formats into. What
I have a textarea that someone can put code in. When someone clicks Submit
I have a textarea that I'm able to edit with the jeditable plugin but
I have a textarea that is used as the body of an email sent

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.