jQuery to style Hyperlinks based on URL extension
This was easy to implement using jQuery. What is required is to select hyperlinks based on their extension and then apply CSS. Below piece of jQuery code based on URL extension, assign font color.
$(document).ready(function() { $("a[href$=pdf]").css("color", "Red"); $("a[href$=png]").css("color", "green"); $("a[href$=jpg]").css("color", "blue"); $("a[href$=html]").css("color", "maroon"); });?
See result below
In this jQuery code, use "$" sign at the end of href property which selects all the hyperlinks with href property value ending with "pdf", "jpg", "png" or "html" string. And once found then do the rest.
Feel free to contact me for any help related to jQuery, I will gladly help you.