jquery - Can't select SPAN sibling -
Does not understand why this code changes the color of the DIV element in blue, but the color of the span element is changed does not do. any idea?
& lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://code.jquery.com/jquery-latest.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("# prev div"). CSS ("color", "blue"); $ ("# prev ~ span"). CSS ("color", "red" );}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Span id = "prev" & gt; Span # prev & lt; / Span & gt; & Lt; Div & gt; Div brother & lt; / Div & gt; & Lt; Span & gt; Duration brother & lt; / Span & gt; & Lt; / Body & gt; & Lt; / Html & gt; Note that if I
< Span id = "prev" & gt; Span # prev & lt; / Span & gt; with
& lt; P id = "prev" & gt; Span # prev & lt; / P & gt; Both DIV and SPAN change the text color.
Thank you!
It looks like you got a bug.
$ ("# prev: span: not (#prev)") works, like $ ("# prev"). Siblings ("span").
Comments
Post a Comment