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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:12:55+00:00 2026-06-16T23:12:55+00:00

I am trying to find a data attribute from an html input in jquery.

  • 0

I am trying to find a data attribute from an html input in jquery. Using
$(this).attr("data-jsonid"); in the code below:

$.fn.serializeObject = function () {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function () 
        {
            if(!isNaN(this.name))
            {
                var currentId = $(this).attr("data-jsonid");

                if (currentId !== undefined)
                {
                    alert(currentId);
                }
                if (o[this.name] !== undefined) 
                {
                    if (!o[this.name].push) 
                    {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } 
                else 
                {
                    o[this.name] = this.value || '';
                }
            }
        });
        return o;
    };
    $(function () {
        $('form').submit(function () {
            $('#result').text(JSON.stringify($('form').serializeObject()));
            return false;

I can see in my html source that all of my text inputs have a data-jsonid attribute, but I am unable to ever determine what it is in javascript/jquery. I can only find the name and value when debugging.

I’ve created a jsfiddle project to aid in this explanation, http://jsfiddle.net/mvargos/dSz38/. If you click “Submit Query” the json of the page is printed. My end goal is that I want to be able to read the data-jsonid attribute so that I can format the way my json is saved if this attribute exists.
Currently the json is saved as

`{"1028":["Matt","Varg","27","2","Cris","Vargz","23","A"]}`

but once I can determine the data-jsonid, I would like to create the json similar to:

`"1028":[{"id":"1", "tenantInfo":["Matt","Varg","27","2"]},{"id":"2", "tenantInfo":["Cris","Vargz","23","A"]}]`

I am unsure if I am just doing something wrong syntax wise or making some other error. Thank you for your help and please let me know if this explanation is poor.

  • 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-16T23:12:56+00:00Added an answer on June 16, 2026 at 11:12 pm

    Before serializing, you can ‘remember’ the jQuery version of this:

    $.fn.serializeObject = function() {
    
       var $this = $(this);
    
       ...
    

    And then you can use $this, when you want to use it as a jQuery object.

       $this.data('some-data-attr');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find and replace html data using jquery. The jquery script
Trying to find a standard. The CmdLet will process data - multiple input, defined
I'm trying to find how to read data from my database in my iphone
I am trying to plot some data and I am getting this error from
So I have this code from the networkx example, but I'm trying to figure
Overview I am trying to find the jQuery function that matches a selection attribute
I'm trying to find a good approach for tracking event data from videos that
I am using the dojox.charting.widget.Chart2D and I am trying to retrieve the data from
i am trying to find a reliable way to pass this jQuery counter plugin
I trying to find function in PHP that can output the binary data. 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.