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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:11:57+00:00 2026-05-23T18:11:57+00:00

After reading about valHooks in a jQuery defect and more recently seen in a

  • 0

After reading about valHooks in a jQuery defect and more recently seen in a fiddle I searched the jQuery documentation and Google but I can’t find anything other than a short example in the jQuery 1.6 release post. Please can someone explain what valHooks are and why they are useful?

  • 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-23T18:11:58+00:00Added an answer on May 23, 2026 at 6:11 pm

    It is a set of functions that define how to get/set values from DOM elements.

    Not all elements can be set using .value. For example, a select element requires something along the lines of select.options[select.selectedIndex].value.

    The underlying code reveals e.g. how to get/set a select element’s value:

    select: {
            get: function( elem ) {
                var value,
                    index = elem.selectedIndex,
                    values = [],
                    options = elem.options,
                    one = elem.type === "select-one";
    
                // Nothing was selected
                if ( index < 0 ) {
                    return null;
                }
    
                // Loop through all the selected options
                for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
                    var option = options[ i ];
    
                    // Don't return options that are disabled or in a disabled optgroup
                    if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
                            (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
    
                        // Get the specific value for the option
                        value = jQuery( option ).val();
    
                        // We don't need an array for one selects
                        if ( one ) {
                            return value;
                        }
    
                        // Multi-Selects return an array
                        values.push( value );
                    }
                }
    
                // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
                if ( one && !values.length && options.length ) {
                    return jQuery( options[ index ] ).val();
                }
    
                return values;
            },
    
            set: function( elem, value ) {
                var values = jQuery.makeArray( value );
    
                jQuery(elem).find("option").each(function() {
                    this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
                });
    
                if ( !values.length ) {
                    elem.selectedIndex = -1;
                }
                return values;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading a bit more about how Gnutella and other P2P networks function, I
After reading an article about the subject from O'Reilly , I wanted to ask
After reading this discussion and this discussion about using CrashRpt to generate a crash
After reading Practical Common Lisp I finally understood what the big deal about macros
After, reading and understanding Dan Benjamin's post about installing Ruby, Rails, etc. on OSX
After reading about both, I just have curiosity, how programming community uses this? In
After reading about using react in actors in Scala, I thought react 's would
After reading about the differences between appSettings and applicationSettings in a web.config file, I'd
After reading about Erlang's lighweight processes I was pretty much sure that they were
After reading about Enitity Framework , i have some questions: 1] What is the

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.