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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:33:33+00:00 2026-06-02T22:33:33+00:00

I have 4 divs with a random number inside of them When calling $(#result1

  • 0

I have 4 divs with a random number inside of them

When calling $("#result1 span").text() the output is blank. However when calling $("#result1 span").html() the output gives the value.

How can I get the value without the html?

The output is like this:

<style type="text/css">
        #number {position:relative; top:-225px;left:584px;width:230px;height:10px;}
        #number span {padding:14px; margin:2px; color:orange; font-size:30px;}
        #number input:hover{opacity:0.9; filter:alpha(opacity=90);}
        #number input{opacity:1.0; filter:alpha(opacity=100);}
        #generate {position:relative; top:35px; left:-1px; width:95px; height:25px;}
        #reset {position:relative; top:35px; left:5px; width:95px; height:25px;}
    </style>1

The value I need is right after the closing </style> tag "1"

Full html:

<div id="number">
<span id="result1"></span>
<span id="result2"></span>
<span id="result3"></span>
<span id="result4"></span>
<button id="generate">Generate</button>
<button id="reset">Restart</button>
</div>

Javascript:

$('#result1').html((Math.random() * 10) >> 0);
$('#result2').html((Math.random() * 10) >> 0);
$('#result3').html((Math.random() * 10) >> 0);
$('#result4').html((Math.random() * 10) >> 0);
  • 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-02T22:33:37+00:00Added an answer on June 2, 2026 at 10:33 pm

    One thing at least– your selector is wrong. $(“#result1 span”).text() isn’t going to give you anything because there is no span inside result1, result1 is a span. Change your selector to $(“#result1”) and see what you get.

    simply changing the selector works for me:

    http://jsfiddle.net/ccross59/TnbCc/1/

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

Sidebar

Related Questions

I have a list which have divs inside it.. Now when i use nested
I have DIVs with OL>LI lists in them, the lists are each sortable and
Can anyone help me with javascript that hides divs matching a specific random number?
I have a set of divs with random ids: <div id=container> <div id=2></div> <div
I have requirement like i will dynamically get a set of divs having random
I have a page (myPage.aspx) that contains a number of divs. EG. <div class=quote>something
I have a random amount of DIVs (minimum 1, max of 10) <div id=container>
I have Divs show and hide (with an animation) using the following script (I
I have divs that I want to display at specific times throughout the day.
Have three divs in a container that I want to float over a large

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.