george Posted August 7, 2014 Share Posted August 7, 2014 (edited) I have a very simple jQuery line of code that is not working. $("p#t1").css("color","#ffffff"); In my document I have a P tag with an ID of t1. I have attached my entire HTML file should this be helpful. TIA My ID of t1 is not declared in my CSS. Could this be the problem? I am going to declare it now. triangle.html Edited August 7, 2014 by george Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2014 Share Posted August 7, 2014 Are there any Javascript errors in your developer console? Link to comment Share on other sites More sharing options...
Mudsaf Posted August 7, 2014 Share Posted August 7, 2014 (edited) Nvm Edited August 7, 2014 by Mudsaf Link to comment Share on other sites More sharing options...
dsonesuk Posted August 7, 2014 Share Posted August 7, 2014 (edited) You can't nest block pre element within paragraph, what is happening is a closing paragraph is created immediately following the opening tag, and vice versa with closing paragraph tag creating empty paragraphs. So no text, and nothing to apply color. EDIT: Oh yea, change to block element like div Edited August 7, 2014 by dsonesuk Link to comment Share on other sites More sharing options...
es131245 Posted August 10, 2014 Share Posted August 10, 2014 Try this $("p#t1").css({"color","#ffffff"}); Link to comment Share on other sites More sharing options...
dsonesuk Posted August 10, 2014 Share Posted August 10, 2014 Wrong syntax $("p#t1").css({"color": "#ffffff"}); but still won't work! as already said browser renders <p id="t1"><pre>.t1 { border-color: blue red green yellow; border-style:solid;} </pre> </p> AS <p id="t1"></p><pre>.t1 { border-color: blue red green yellow; border-style:solid;} </pre> <p> </p> Link to comment Share on other sites More sharing options...
george Posted August 10, 2014 Author Share Posted August 10, 2014 Problem fixed, as I did change it to <div ="t1"><pre>.t1 { border-color: blue red green yellow; border-style:solid;}</pre></div> and that did correct my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now