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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:02:28+00:00 2026-06-05T15:02:28+00:00

I understand this is an easy question but for some reason this just isn’t

  • 0

I understand this is an easy question but for some reason this just isn’t working for me. I have a function that is triggered everytime a drop down menu is changed. Here is the relevant code that is suppose to grab the current value of the text field, if a value exists, clear it that is contained within the .change function:

var doc_val_check = $('#doc_title').attr("value");
    if (doc_val_check.length > 0) {
        doc_val_check == "";
    }

I feel like I am missing something very simple.

  • 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-05T15:02:31+00:00Added an answer on June 5, 2026 at 3:02 pm
    doc_val_check == "";   // == is equality check operator
    

    should be

    doc_val_check = "";    // = is assign operator. you need to set empty value
    
                           // so you need =
    

    You can write you full code like this:

    var doc_val_check = $.trim( $('#doc_title').val() ); // take value of text 
                                                         // field using .val()
        if (doc_val_check.length) {
            doc_val_check = ""; // this will not update your text field
        }
    

    To update you text field with a "" you need to try

    $('#doc_title').attr('value', doc_val_check); 
    // or 
    $('doc_title').val(doc_val_check);
    

    But I think you don’t need above process.


    In short, just one line

    $('#doc_title').val("");
    

    Note

    .val() use to set/ get value in text field. With parameter it acts as setter and without parameter acts as getter.

    Read more about .val()

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

Sidebar

Related Questions

This is probably a really easy question to answer, but for some reason I'm
I don't understand why this is not working. It should be very easy. upload.php
I understand this is a subjective question but I want to see how others
There are some other variations of this question here at SO, but please read
I think that this should be easy, but I'm not able to get it
This question is messy, i dont need a working solution, i need some psuedo
Maybe this question is so easy... I understand html, css, the dom and javascript
This is probably an easy question to answer, but I don't see it mentioned
I have a question that I've been trying to answer for some time now
Similar to the question I posted yesterday , I have this problem that I

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.