jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes Jquery Wrong Markup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Jquery Wrong Markup" Watch "Jquery Wrong Markup" New topic
Author

Jquery Wrong Markup

Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi,

I am trying to understand why Jquery generates the wrong markup as I am seeing on my firebug HTML console.

I use JSON to fetch data from db..


Now, after getting the data, I am appending it to the div with a checkbox in front and a span.

But, the html mark up seems wrong on the checkbox..



I was expecting something like this (with the input type checkbox terminated with a forward slash).


I think I explicitly set it in my ajax call. Am I missing something?
<input type='checkbox' value='" + value.strStationCode + "'" + "/>"

As for the display, there's no problem.


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
That missing slash means nothing.

And are you sure it is jQuery that is doing it and not the browser or whatever you are viewing the source with.

Eric
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Eric,

And are you sure it is jQuery that is doing it and not the browser or whatever you are viewing the source with


I ran this code on my mozilla firebug and I checked out at the HTML tab of the firebug console on what exactly is being appended at the DOM after the call to $.getJSON returns.

This is the one thing that I notice. Maybe this isn't jquery specific or its only my firebug.
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

Are you sure the code you posted is the same that is getting used?
You don't seem to have any closing <span> element in the code, yet it appears in your browser?
Also you don't have <li> in the html you posted.

Sean


I love this place!
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Sean,

Are you sure the code you posted is the same that is getting used?


Too much editing perhaps. Good catch!
This code is a part of a much larger function, I did a lot of deletion just to show my point.

Anyway, I just notice it in my firebug. Its not displaying fully xhtml compliant tag, I notice that even if I write they are translated to
.

Maybe its just in the firebug html tab display. Not really big deal so as long as everything gets displayed correctly.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

It's just a markup display issue. Nothing at all to do with jQuery, and nothing to be concerned about.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jquery Wrong Markup