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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:11:49+00:00 2026-06-13T08:11:49+00:00

My question is more regarding the best way/practice how to realise one thing. Lets

  • 0

My question is more regarding the best way/practice how to realise one thing. Lets assume I have a possibility to create a html code for JQuery to retrieve some text value. What is the best way to do it?

I know you can just get a value using the get by id and so on, so basically I could create my own div with unique ID and by JQuery retrieve some value in it. But is this the good way? Of course another thing is that the value should not be seen by the people.

Maybe I should put the value as an attribute? Key, value pair? And get element by id and get the attribute?

So any suggestions, the best way to store one value on the page and easily retrieve it?

Thanks in advance

An update:

An example:
I do something as following:

<div id="uniqueID" style="display:none"> Value which in need </div>

This is some solution, then i just need to retrieve this value with JQuery, simple.
But what i whant to know is there a better way, maybe there is some special tag in HTML, or something that other people prefer, etc …

By jquery i just say something like:

$("#uniqueId").val()

And there should not be anything more complicated queiet simple, didn’t know it could be so unclear.

  • 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-13T08:11:50+00:00Added an answer on June 13, 2026 at 8:11 am

    If you just want your server to embed a value in your page that is not visible to the viewer that you can then retrieve in javascript, you might as well just have your server put the value in a javascript variable directly. There is no reason to put it in the DOM if you just need it in javascript.

    For example, you can just put this in your page:

    <script>
    var myValueSetByServer = "foo";
    </script>
    

    Then, you can just access myValueSetByServer anywhere in the page javascript. There is no need to put it in a div or on an attribute or anything like that.

    If you were going to have lots of these, you could just define an object and make your values all be properties on the object:

    <script>
    var myServerValues = {prop1: "foo", prop2: "whatever", user: "fred", type: "person"};
    </script>
    

    Of course, there are many other ways to store things in the actual page like you have mentioned including a data attribute on a DOM node, the text value of a hidden DOM node, etc… but none are as simple as just putting the value in a javscript variable if you just want to use the value from javascript.

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

Sidebar

Related Questions

I have a question about best practices regarding how one should approach storing complex
I have a question regarding iOS (or perhaps more accurately Objective-C) and properties. I
I have a question regarding how to best accomplish something in WPF MVVM. I
Hey, I have a question regarding code structure, and was wondering what the best
I have a question regarding best practices when adding targets to a UIButton on
This is a code review question more then anything. I have the following problem:
ASP.Net MVC3 is cool and all but I have this question more out of
One more question about most elegant and simple implementation of element combinations in F#.
This question is more a re-insurance than one directly about how to code. As
I have a question regarding setting up a custom delegate class for use with

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.