I having a hyperlink generation like below
$element.html(indicator.link(url)); but it comes in typical hyperlinks blue color. How can I change the color of the font of this hyperlink in javascript?
I having a hyperlink generation like below
$element.html(indicator.link(url)); but it comes in typical hyperlinks blue color. How can I change the color of the font of this hyperlink in javascript?
It's best to do this with CSS. JavaScript is for modifying behavior, while CSS is used for styling. Using JavaScript for this is highly frowned upon.
That said, this question depends on what type of state the link is in. For unvisited links, use the :link pseudoselector.
a:link { color: green; } <a href="http://www.espn.com">Visit ESPN!</a> For links you've already visited, you can now use the :visited pseudo-class.
a:visited { color: red; } <a href="http://www.youtube.com">Visit YouTube!</a> For links you are just hovering over, use :hover
a:hover { color: pink; } <a href="http://www.pineapplesandoranges.com">Pineapples and Oranges</a> You should absolutely not use JavaScript. But here is the solution for it anyways.
var link = document.getElementById("my-link"); link.style.color = "green"; <a id="my-link" href="http://www.zebras.com">Zebras</a> try:
$element.html(indicator.link(url)); $element.css('color','#000'); Or:
$('a').css('color','#000'); But this would make all links with a tag turn black.
well look like if like you are working with Jquery
One option is with the .css()
$element.html(indicator.link(url)); $element.css( "color", "red" );