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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:12:09+00:00 2026-05-15T14:12:09+00:00

I have a block-level HTML element that contains multiple block-level and inline-level elements, e.g.

  • 0

I have a block-level HTML element that contains multiple block-level and inline-level elements, e.g.

<div id="ajax">
   <h2>Something</h2>
   <div class="icon"></div>
   <div class="clear"></div>
   <div class="somethingelse"><h3>blah</h3></div>
</div>

I simply want to attach a jQuery ajax() event to a click on #ajax (the top-level element), but I need to pass through a few parameters to the server-side script.

One possible way I’m seeing is simply replacing div#ajax with a#ajax, which would allow me to add something like href="param=value&this=that", but this would render the page invalid: there can’t be any block-level elements (<div>) inside of an inline element (<a>).

Another possible way would be adding a rel attribute to div#ajax, which would also mean neglecting XHTML validation.

I don’t want to go adding inline onclick events to divs, that’s a little too far out… Also, turning all children of div#ajax into e.g. <span> would be a major pita.

How would you handle this?

  • 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-15T14:12:09+00:00Added an answer on May 15, 2026 at 2:12 pm

    There are several ways to go about this while maintaining XHTML validity, or at least remaining full functional in all browsers:

    First option, put the parameters directly in JavaScript somewhere, this is the simplest.


    Second, if you can’t do this in the script, you can use the anchor, but inside, not wrapping it, like this:

    <div id="ajax">
       <h2>Something</h2>
       <div class="icon"></div>
       <div class="clear"></div>
       <div class="somethingelse"><h3>blah</h3></div>
       <a class="params" href="page.htm?param=value&this=that"></a>
    </div>
    

    CSS Hiding it:

    .params { display: none; }
    

    And jQuery using it:

    $("#ajax").click(function() {
       $.ajax({
         url: $(this).find(".params").attr("href");
         success: function() {
           //do something
         }
       });
    });
    

    Third, use HTML5 data attributes, this will break strict XHTML validity, but a great future way to go, it’ll cause no problems in current browsers.


    Last option (that I can think of), use the jQuery metadata plugin or storing what you want.

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

Sidebar

Related Questions

I have a block of HTML code that contains a button <button class=someButton onclick=openPage('test')></button>
I have a block element (DIV) who stretches across an entire page. It contains
I've heard that putting a block element inside a inline element is a HTML
I have a block level element, a container, that should be hidden when all
I have often wrapped block level elements with <a> tags in order to make
I have a block level element which I am centering on the page. I
I have an HTML/XML table generated by AJAX that displays limited columns of a
In HTML, should block level elements always wrap <a> tags? What if it's necessary
I have block level elements with its height property set in % . Inside
I have a block of text that I need to give a background colour

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.