javascript jquery add stylesheet if class is present -
can tell me why following doesn't work in 'head'
<script type="text/javascript"> if ($('.company-color').length){ document.write("<link rel='stylesheet' href='company-color.css' type='text/css'>"); } </script>
i have class present on pages , want insert above stylesheet page if class '.company-color' present.
use
jquery(function($){ if ($('.company-color').length){ $('body').append("<link rel='stylesheet' href='company-color.css' type='text/css'>"); // or head } })
Comments
Post a Comment