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 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

This is more of a conceptual question. After reading about Jquery Mobile, it got
I have a few questions about this after reading the iPhone documentation on it:
I recently started reading about ASP.net MVC and after getting excited about the concept,
After reading about Mapper XMLs I can't help to wonder how one might go
After reading about the problem of passing empty std::string objects between DLLs and EXEs,
After reading a description about swapping pointer addresses on Stackoverflow, I have a question
After reading an article about fonts, i tried the code and i am getting
After reading some articles about XSS I have incorporated HTMLPurifier into my zend framework
Im skinning a progressBar in Flex, and after reading a bit about it, I
After reading http://www.w3schools.com/tags/tag_noscript.asp confused about onclick event on noscript tag. Anybody knows the purpose?

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.