dodgeitorelse3 Posted March 7, 2018 Share Posted March 7, 2018 (edited) I have been working on this code for quite some time var ul = top.document.getElementById("sub-menu"); var li = top.document.createElement("li"); var a = document.createElement('a'); var stradd = " (tours.ini not found)"; var linkText = document.createTextNode("<?php echo $loguname;?>"+stradd); a.appendChild(linkText); a.href = "tours_U/<?php echo $loguname;?>/tours.ini"; li.appendChild(a); li.setAttribute("name", "tours_download[]"); li.setAttribute("id", "li<?php echo $loguname;?>"); li.style.fontSize="12px"; ul.appendChild(li); what I am having trouble doing is setting the color of stradd variable. I cannot figure out how to access just that part to make the font color white (parenthesis included). Where can I find documentation to help me sort this out? Edited March 7, 2018 by dodgeitorelse3 Quote Link to comment https://forums.phpfreaks.com/topic/306763-set-partial-text-color-via-javascript/ Share on other sites More sharing options...
dodgeitorelse3 Posted March 7, 2018 Author Share Posted March 7, 2018 my bad I meant to put this in the javascript forum, can an admin please move it? Quote Link to comment https://forums.phpfreaks.com/topic/306763-set-partial-text-color-via-javascript/#findComment-1556981 Share on other sites More sharing options...
Solution gizmola Posted March 7, 2018 Solution Share Posted March 7, 2018 You can't just randomly color a piece of text. What you can do however, is put a span around that section, and style the span. Quote Link to comment https://forums.phpfreaks.com/topic/306763-set-partial-text-color-via-javascript/#findComment-1556982 Share on other sites More sharing options...
HemendraSingh Posted March 7, 2018 Share Posted March 7, 2018 Debugging your code & find error in each line. Check your text line in debugging a.appendChild(linkText); Quote Link to comment https://forums.phpfreaks.com/topic/306763-set-partial-text-color-via-javascript/#findComment-1556994 Share on other sites More sharing options...
dodgeitorelse3 Posted March 8, 2018 Author Share Posted March 8, 2018 thank you gizmola, no idea why I didnt think of that. @HemendraSingh, Thank you. I will have to learn how to debug javascript and then I will see what you were getting at for that line of code. Quote Link to comment https://forums.phpfreaks.com/topic/306763-set-partial-text-color-via-javascript/#findComment-1557036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.