Wednesday, 15 June 2011

javascript - I have a message output, I would like to have one word orange and the rest normal -



javascript - I have a message output, I would like to have one word orange and the rest normal -

i word bournemouth red, rest of words inherit p styling.

<script type="text/javascript"> $(document).ready(function() { var = new date(); var hours = now.gethours(); var msg; if (hours >= 0 && hours <= 12) msg = "today's lunch deals in bournemouth"; else if (hours >= 13 && hours <= 19) msg = "tonight's dinner deals in bournemouth"; else msg = "tomorrow's lunch deals in bournemouth"; $('#time p').text(msg); }); </script> <div id="time" style="position:absolute; width:100%; padding-top:90px; text-align:center; font-family: arial, helvetica, sans-serif; font-weight:bold; color:#fff; font-size:17px;"> <p></p> </div>

are there tags need utilize jquery colors? tried html, printed out code.

you don't colour jquery (or @ to the lowest degree not directly, can modify css it)

try this:

if (hours >= 0 && hours <= 12) msg = "today's lunch deals in <span class='red'>bournemouth</span>"; else if (hours >= 13 && hours <= 19) msg = "tonight's dinner deals in <span class='red'>bournemouth</span>"; else msg = "tomorrow's lunch deals in <span class='red'>bournemouth</span>";

then in html file:

<style> .red { color: red; } </style>

you need swap .text( .html(

javascript jquery html css

No comments:

Post a Comment