[jQuery] Re: closing tag bug in jQuery 1.2.6?
I'm fairly certain that's incorrect syntax (putting a div inside a span - especially one that's self-closing). The browser will automatically force the div outside the span. --John On Wed, Oct 29, 2008 at 11:38 AM, Jay [EMAIL PROTECTED] wrote: Has someone else already posted this bug? The following code shows jquery failing to detect the termination of a tag. Load the page and click on the word login. The selector should find the empty div and display the html content (nothing). Instead shows the span closing tag and the javascript that follows. html head titlejQuery bug test Page/title script src=script/jquery-1.2.6.min.js type=text/javascript/ script /head body style=background-color:black span id=Login style=position:absolute; top:20px; left:5%; width: 90%; z-index:12; span id=LoginToggle style=float:right; color=green;Login/span div class=popupContent style=float:right; / /span script type=text/javascript !-- $( function() { $(#LoginToggle).click( function(){ alert( $ ( '#Logindiv.popupContent' ).html() ); }); } ); //-- /script /body /html If you change the div closing it works correctly. Change this: div class=popupContent style=float:right; / To this: div class=popupContent style=float:right; /div Does the same in IE7 and FF3
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 10:46 am, John Resig [EMAIL PROTECTED] wrote: I'm fairly certain that's incorrect syntax (putting a div inside a span - especially one that's self-closing). The browser will automatically force the div outside the span. Why does it work as I expected if the tag is not self closing? If it's forced outside the behaviour should be identical in either case. I'll go read up on what the span tag is supposed to do. It seems valid to me that if I wanted to apply format attributes to a bunch of elements I could surround it with a span. I'm really begginning to think I should go back to assembler programming. It was simpler.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
Hey Jay, I remember having some confusion about the span tag at some point. the html specs do significantly limit the types of tags that can be used inside it and browsers will do unexpected things if you try. definitely look at the w3c site to get some more specifics. On Wed, Oct 29, 2008 at 12:04 PM, Jay [EMAIL PROTECTED] wrote: On Oct 29, 10:46 am, John Resig [EMAIL PROTECTED] wrote: I'm fairly certain that's incorrect syntax (putting a div inside a span - especially one that's self-closing). The browser will automatically force the div outside the span. Why does it work as I expected if the tag is not self closing? If it's forced outside the behaviour should be identical in either case. I'll go read up on what the span tag is supposed to do. It seems valid to me that if I wanted to apply format attributes to a bunch of elements I could surround it with a span. I'm really begginning to think I should go back to assembler programming. It was simpler. -- Christopher Thatcher
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 11:08 am, chris thatcher [EMAIL PROTECTED] wrote: Hey Jay, I remember having some confusion about the span tag at some point. the html specs do significantly limit the types of tags that can be used inside it and browsers will do unexpected things if you try. definitely look at the w3c site to get some more specifics. head explodingARG!/head exploding
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 2008, at 12:10 PM, Jay wrote: On Oct 29, 11:08 am, chris thatcher [EMAIL PROTECTED] wrote: Hey Jay, I remember having some confusion about the span tag at some point. the html specs do significantly limit the types of tags that can be used inside it and browsers will do unexpected things if you try. definitely look at the w3c site to get some more specifics. head explodingARG!/head exploding What? no rules were used when you coded in assembly? it is very easy to validate against an (X)HTML dtd. If you do so, you will save yourself a lot of headaches and have your pages display / most/ similar across browser. Pick a DTD (xhtml strict is nice...) and validate against it.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Wed, Oct 29, 2008 at 12:04 PM, Jay [EMAIL PROTECTED] wrote: I'll go read up on what the span tag is supposed to do. It seems valid to me that if I wanted to apply format attributes to a bunch of elements I could surround it with a span. A div is a better fit than span in that case. - Richard
[jQuery] Re: closing tag bug in jQuery 1.2.6?
What? no rules were used when you coded in assembly? There are always rules in everything. In assembler they're predictable and absolute though. With html a lot of things are only 'hints' and it invisibly does whatever it wants without telling you what happened. Add to that different browsers do it differently. I'd rate html as harder personally. Understanding what a single instruction of assembler does is trivial. it is very easy to validate against an (X)HTML dtd. If you do so, you will save yourself a lot of headaches and have your pages display / most/ similar across browser. Pick a DTD (xhtml strict is nice...) and validate against it. In this case a strict xhtml doctype made no difference in the behaviour of the jquery. I didn't expect it would but I checked anyway. My reading of the xhtml standard seemed to indicate including javascript snippets while doing dynamic page construction was outside the standards. The browsers do it any way since it's the only reasonable way to accomplish some tasks. The browsers don't all behave within the standards or even in a common way. Standards are great. Everyone should have several. ;) http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.4 I haven't had time to do an exhausitve search but nowhere in the span tag description does it specifically state what tags it may or may not enclose. Care to share a link to what you use for xhtml validation?
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 11:34 am, Richard D. Worth [EMAIL PROTECTED] wrote: A div is a better fit than span in that case. Thanks Richard. That works as well as what I had and I'm closer to good practice.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
Care to share a link to what you use for xhtml validation? I use my editor, but if you don't have a validating editor, you could use: http://validator.w3.org/
[jQuery] Re: closing tag bug in jQuery 1.2.6?
hehe. It's easy once you get to know the intrincacies between CSS and XHTML. A span is an in-line element, it's purpose is to separate a 'span' of text. That's why you can't put a block element (i.e a div) inside. Most elements are either in-line or block level, so it's easy to know what fits. in your code I see two problems: 1. style=float:right; color=green; that causes a parsing error, should be style=float:right,color:green 2. div / You can't self close a DIV, even if it's empty. The XHTML specs allow it, but browser currently can't handle it: (found at http://www.w3.org/TR/xhtml1/#C_3) Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use p /p and not p /). The only elements with an EMPTY content model are link /, meta /, input /, br /, hr / and img / - ricardo On Oct 29, 2:10 pm, Jay [EMAIL PROTECTED] wrote: On Oct 29, 11:08 am, chris thatcher [EMAIL PROTECTED] wrote: Hey Jay, I remember having some confusion about the span tag at some point. the html specs do significantly limit the types of tags that can be used inside it and browsers will do unexpected things if you try. definitely look at the w3c site to get some more specifics. head explodingARG!/head exploding
[jQuery] Re: closing tag bug in jQuery 1.2.6?
http://validator.w3.org/ Thanks Robert.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On 29 Okt., 18:24, Jay [EMAIL PROTECTED] wrote: What? no rules were used when you coded in assembly? There are always rules in everything. In assembler they're predictable and absolute though. With html a lot of things are only 'hints' and it invisibly does whatever it wants without telling you what happened. That's because hordes of HTML authors didn't care to learn/write HTML properly and thus browser vendors had to make browsers, e.g. their HTML parsers very error forgiving (mostly referred to tag soup parsers) - also because no error handling was ever specified in those specs. Interestingly this is going to be addressed in the HTML 5 specification. --Klaus
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 12:28 pm, ricardobeat [EMAIL PROTECTED] wrote: hehe. It's easy once you get to know the intrincacies between CSS and XHTML. LOL! Maybe someday. in your code I see two problems: 1. style=float:right; color=green; that causes a parsing error, should be style=float:right,color:green Sorry, typo. You can't self close a DIV, even if it's empty. The XHTML specs allow it, but browser currently can't handle it: (found athttp://www.w3.org/TR/xhtml1/#C_3) Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use p /p and not p /). The only elements with an EMPTY content model are link /, meta /, input /, br /, hr / and img / Thanks Ricardo. I learned a lot from you guys today.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On 29 Okt., 18:28, ricardobeat [EMAIL PROTECTED] wrote: 2. div / You can't self close a DIV, even if it's empty. The XHTML specs allow it, but browser currently can't handle it: (found athttp://www.w3.org/TR/xhtml1/#C_3) Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use p /p and not p /). To clarify: this is an excerpt of the HTML Compatibility Guidelines, which apply if you serve XHTML as text/html, resulting in browsers using its tag soup parser. If you'd send XHTML as true XML (application/xhtml+xml) an XML parser is going to be used and a div/ would be perfectly understood by such an XML capable browser. IE up to version 8 though is not capable which is why a lot of people (me included) consider XHTML as a dead end today and recommend to use HTML 4 in the first place (which is what XHTML as text/html is anyway from the browser perspective). --Klaus
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Oct 29, 2008, at 1:39 PM, Jay wrote: On Oct 29, 12:28 pm, ricardobeat [EMAIL PROTECTED] wrote: hehe. It's easy once you get to know the intrincacies between CSS and XHTML. LOL! Maybe someday. in your code I see two problems: 1. style=float:right; color=green; that causes a parsing error, should be style=float:right,color:green Sorry, typo. You were right, ricardo is wrong. -Rob You can't self close a DIV, even if it's empty. The XHTML specs allow it, but browser currently can't handle it: (found athttp://www.w3.org/TR/xhtml1/#C_3) Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use p /p and not p /). The only elements with an EMPTY content model are link /, meta /, input /, br /, hr / and img / Thanks Ricardo. I learned a lot from you guys today.
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On Wed, Oct 29, 2008 at 1:59 PM, Robert Koberg [EMAIL PROTECTED] wrote: On Oct 29, 2008, at 1:39 PM, Jay wrote: On Oct 29, 12:28 pm, ricardobeat [EMAIL PROTECTED] wrote: hehe. It's easy once you get to know the intrincacies between CSS and XHTML. LOL! Maybe someday. in your code I see two problems: 1. style=float:right; color=green; that causes a parsing error, should be style=float:right,color:green Sorry, typo. You were right, ricardo is wrong. They were both wrong. First has = instead of : second has , instead of ; - Richard
[jQuery] Re: closing tag bug in jQuery 1.2.6?
hehe. It's easy once you get to know the intrincacies between CSS and XHTML. LOL! Maybe someday. in your code I see two problems: 1. style=float:right; color=green; that causes a parsing error, should be style=float:right,color:green Sorry, typo. You were right, ricardo is wrong. They were both wrong. First has = instead of : second has , instead of ; oops, didn't notice the equals :) - Richard
[jQuery] Re: closing tag bug in jQuery 1.2.6?
On 29 Okt., 18:24, Jay [EMAIL PROTECTED] wrote: http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.4 I haven't had time to do an exhausitve search but nowhere in the span tag description does it specifically state what tags it may or may not enclose. This part of the DTD is important: !ELEMENT SPAN - - (%inline;)* -- generic language/style container -- It says, that the span element cannot contain anything but inline elements and text (again from the DTD: character level elements and text strings). Reading DTDs is an art of itself and it sucks. Quite good read by the way: http://www.dev-archive.net/articles/xhtml.html --Klaus