Hi Giuliano,
I tried to reproduce your problem, but both types of selectors worked
fine for me.
I used jQuery 1.1.1 packed (Rev. 1173).
You can see the test here:
http://test.learningjquery.com/ids.htm
Here is the relevant script and css placed in the <head>:
<script type="text/javascript">
$(document).ready(function() {
$('#main-content #first-para').addClass('test1');
$('div#second-para').addClass('test2');
});
</script>
<style type="text/css" media="screen">
.test1 {
background: #ff9;
}
.test2 {
background: #cff;
}
</style>
And here is the relevant HTML:
<div id="main-content">
<h2>ID Issues?</h2>
<div id="wrapper">
Using jQuery 1.1.1 Rev. 1173, packed.
<div id="first-para">
<p>Applied selector: <code>$('#main-content #first-para')</
code>, should make the div's background yellow. </p>
</div>
</div>
<div id="second-para">
<p>Applied selector: <code>$('div#second-para')</code>, should
make the div's background light blue.</p>
</div>
</div>
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jan 25, 2007, at 3:17 PM, Giuliano Marcangelo wrote:
Jennifer,
I am far from being an expert, but as you know an id must be
unique..........therefore .myClass #myId is not necessary to target
#myId.........surely you should only target the "id"....same with
"#firstId #secondId"........simply declare the id that you wish to
target
hth
On 25/01/07, jgrucza <[EMAIL PROTECTED]> wrote:
I have a somewhat similar problem with ID selectors, and I posted a
message
about it and a bug but so far I haven't gotten a single response
from anyone
(here's the bug: http://jquery.com/dev/bugs/bug/881/).
My problem is IDs preceded by a class or another ID (i.e. ".myClass
#myId"
or "#firstId #secondId"). It's causing an exception in the jquery
code on
this line:
if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
I don't know if it's related to yours or not.
-Jennifer
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/