+ 1

JQuery.css() not working...

I have JQuery ready to use... it's working , It creates my element.. But , For some reason when i try to modify my "div" css no change is made.. Any help? code: player=$('<div id="p1" class="p1">hi</div>'); $("div").css({"width" : "25px", "height" : "25px", "background-color" : "#000"}); $("body").append(player); I've tried ("div").css as well as (".p1").css ... Neither of them work..

29th Sep 2017, 8:31 PM
Sploit
Sploit - avatar
2 Answers
+ 1
Try to give css after appending the 'player'. I think css function affects only existing elements.
1st Oct 2017, 12:59 PM
Siroj Samadov
Siroj Samadov - avatar
+ 1
Thank You!
1st Oct 2017, 1:10 PM
Sploit
Sploit - avatar