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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:20:14+00:00 2026-05-20T01:20:14+00:00

Issue: In IE 6 & 7, the text of a button element is returned

  • 0

Issue: In IE 6 & 7, the text of a button element is returned in jQuery using .val() or .attr(‘value’), instead of the button’s actual value. This is a known issue and it also occurs with straight Javascript using .value. There was a previous discussion on it here:

Retrieve Button value with jQuery

but an acceptable total solution was never found (only a hack where the button’s text is temporarily hidden).

I have been working on a total solution so that whenever a button’s value is accessed (be it on form submit or even just using jQuery/Javascript), the proper value is returned. I have it working with .val() with the below code. I am seeking help with getting it to also work using .attr(‘value’), and even with straight Javascript .value if possible.

I have set up a JSfiddle page where it can be seen in action here:

http://jsfiddle.net/hyperseer/RVyDN/2/

Code:

$(document).ready(function(){

    $().iefixer();

});

(function($){  

    $.fn.iefixer = function(){  

            $.fn.origval = $.fn.val;
            $.fn.val = function(value){
                var elem = this[0];
                if(value === undefined){
                    var returnVal = null;
                    if( elem.nodeName.toLowerCase() == 'button' )
                    {
                        returnVal = elem.getAttributeNode("value").nodeValue;
                    } else {
                        returnVal = $(elem).origval();
                    }
                    return returnVal;
                } else {
                    if( elem.nodeName.toLowerCase() == 'button' )
                    {
                        elem.getAttributeNode("value").nodeValue = value;
                    } else {
                        $(elem).origval(value);
                    }

                }
            }

$('button').click( function() {

alert( "$(this).val() = " + $(this).val() ); // this works now with above fix
alert( "$(this).attr('value') = " + $(this).attr('value') ); // doesn't work
alert( "this.value = " + this.value ); // straight JS doesn't work

            });

    };

})(jQuery); 
  • 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-20T01:20:15+00:00Added an answer on May 20, 2026 at 1:20 am

    UPDATE:

    I’ve now got it working with both the .val() and .attr(‘value’) functions using the following code:

    $(document).ready(function(){
        $().iefixer();
    });
    
    (function($){  
    
    $.fn.iefixer = function(){  
    
        var ie = $.browser.msie;
        var ver = $.browser.version;
    
        if ( ie && ver<=7 ) {
    
            $.fn.origval = $.fn.val;
            $.fn.val = function(value){
                var elem = this[0];
                if(value === undefined){
                    var returnVal = null;
                    if( elem.nodeName.toLowerCase() == 'button' )
                    {
                        returnVal = elem.getAttributeNode("value").nodeValue;
                    } else {
                        returnVal = $(elem).origval();
                    }
                    return returnVal;
                } else {
                    if( elem.nodeName.toLowerCase() == 'button' )
                    {
                        elem.getAttributeNode("value").nodeValue = value;
                    } else {
                        $(elem).origval(value);
                    }
    
                }
            }
    
         var originalAttr = $.fn.attr;
            $.fn.attr = function(name, val) {
                if (this[0].nodeName.toLowerCase() == 'button' && val === undefined) return $(this).val();
                return originalAttr.apply(this, arguments);    
            }
    
        }      
    
    };
    
    })(jQuery); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# & Mysql I have combobox & button in my webpage, if i
This issue came up when I got different records counts for what I thought
The issue that prompted me to ask this is a web form that was
Our issue is that our project has files being downloaded using wget to the
This issue is driving me mad. I have several tables defined, and CRUD stored
The issue is simple really. Instead of creating folders in Visual Studio, I create
Code: NSString* string3 = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)tvQ.text, NULL, (CFStringRef)@:/?#[]@!$&'()*+,;=, kCFStringEncodingUTF8); My code is working to
This simple issue I know, in my program session variable is already working properly
The issue is there is a database with around 20k customer records and I
another issue in IE 6... link The navbar link list has a border applied

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.