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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:12:31+00:00 2026-06-15T16:12:31+00:00

Consider the following HTML5 code in body: <p id=p1> Email: <input type=text name=email /><br

  • 0

Consider the following HTML5 code in body:

<p id="p1">
    Email: <input type="text" name="email" /><br />
    Name: <input type="text" name="name" /><br />
    <input type="submit" name="submit" value="Submit" />
</p>
<p id="p2">
    <form action="/index.php">
        Email: <input type="text" name="email" /><br />
        Name: <input type="text" name="name" /><br />
        <input type="submit" name="submit" value="Submit" />
    </form>
</p>

And the following javascript code:

$(document).ready(function() {
    alert("$(#p1 input).length: " + $("#p1 input").length + "\n$(#p2 input).length: " + $("#p2 input").length);
});​

Here are different browsers’ outputs:

Internet Explorer 9.0.8112.16421

$(#p1 input).length: 3
$(#p2 input).length: 3

Chromium Version 20.0.1132.47 Ubuntu 12.04 (144678)

$(#p1 input).length: 3
$(#p2 input).length: 0

Mozilla Firefox for Ubuntu 17.0.1

$(#p1 input).length: 3
$(#p2 input).length: 0

Can anyone please explain why?

http://jsfiddle.net/LKStL/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-06-15T16:12:32+00:00Added an answer on June 15, 2026 at 4:12 pm

    Elaborating on my comment:

    Block elements like form aren’t allowed inside p elements. It’s invalid HTML, hence jQuery breaks trying to parse it. I can only speculate that maybe it works in Internet Explorer because Explorer doesn’t follow HTML rendering standards (ie: it should break but doesn’t).

    Solution: Put your form tag outside of the p or change p to an element that allows block elements, like a div.

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

Sidebar

Related Questions

Consider the following code : HTML: <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div>
Consider the following HTML snipped: <input type=submit value=Delete selected><input type=submit value=Print selected> <div class=table>
Consider the following piece of code: <html><head></head> <body> <script type=text/javascript> var outside_scope = outside
Consider the following HTML tables: <table id=myTable1> <tr><td><input type=text id=quantity1 name=quantity1 /></td></tr> <tr><td><input type=text
Consider the following code: <!DOCTYPE html> <html> <body> <script type=text/javascript> var str = '<12>
Consider the following html snippet <!DOCTYPE html> <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.4.2.js ></script> <script
Consider the following code: HTML <a href='#' id='the-button'>Submit</a> JavaScript $(#the-button).click(function(e) { e.preventDefault(); $(#the-form).submit(); });
Consider the following code: require 'nokogiri' # v1.5.2 doc = Nokogiri.XML('<body><a name=foo>ick</a></body>') puts doc.to_html
Consider the following JS code: <script type=text/javascript> $(function() { // Check if landing on
Consider the following HTML: <select data-bind=options: assemblies, optionsText: 'Name', value: selectedAssembly> </select> Name <input

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.