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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:23:35+00:00 2026-05-30T09:23:35+00:00

My div structure should be this: <div id=dashboard> <img id=pic1 src=…png /> <h6>….</h6> </div>

  • 0

My div structure should be this:

<div id="dashboard">
    <img id="pic1" src="...png" />
    <h6>....</h6>       
</div>

To create the div I use this:

$('<div>', {
    'id': 'dashboard'
}).appendTo('body');

I need to append a h6 tag with text into the above div. How can this be done? Also how can I access the text within the h6 tag when the div is clicked?

$('#dashboard div').hover(function() {
    alert($(this).children().eq(2)  ??  );
};
  • 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-30T09:23:37+00:00Added an answer on May 30, 2026 at 9:23 am

    To add the h6 element, try this:

    var $div = $('<div>', {
        'id':'dashboard'
    }).appendTo('body');
    
    $("<h6></h6>").text("Foo").appendTo($div);
    

    To access the text of the h6 on click of the div, try this:

    $("body").delegate("#dashboard", "click", function() { 
        var text = $("h6", this).text();
        alert(text);
    });
    

    That assumes you are using jQuery 1.6 or lower. If you are using jQuery 1.7+, you can use on():

    $("body").on("click", "#dashboard", function() { 
        var text = $("h6", this).text();
        alert(text);
    });
    

    Example fiddle

    Also, I have used $("body") here as an example – you should use a selector which is the closest to the element you are attaching the event to (in this case #dashboard) which is not dynamically created.

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

Sidebar

Related Questions

My HTML structure looks like this <div class=container> <div class=image><img /></div> <div class=title_body> <div
I have below structure <div class=mybox> <div id=imageslide> <a href=><img src=url /></a> </div> </div>
How should I create this kind of structure? My first idea was to combine
If I have a structure like this: <body> <div data-role=page data-dom-cache=true id=foo>...</div> <div data-role=page
I have this div structure <div class=panel> <div class=north></div> <div class=center></div> </div> The outer
The html structure looks like this <div id=parent> parent may contain text <div id=child1>
I have this HTML structure <div class=buttons> <button data-icon=ui-icon-disk class=save>Save1</button> <button data-icon=ui-icon-check class=ok>OK1</button> <button
I need to call the jquery.animate on a nested div. The div structure is
My HTML structure is like this : <div class=controls> <input id=car class=span3 type=text placeholder=B.E
I have a div like this: <div class=someDiv> <span>This content should remain</span> The rest

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.