I am trying to modify the css of a class depending on the URL. Here is the currently non-working code:
JS:
<script>
//<![CDATA[
if (location.pathname == "/SearchResults.asp"
|| location.pathname.indexOf("-s/") != -1
|| location.pathname.indexOf("_s/") != -1)
$('.colors_productname span').css("background-color", "#F7F7F7");
//]]>
</script>
HTML:
<div>
<a href="#" class=
"productnamecolor colors_productname" title="Cracked Pepper"><span itemprop=
'name'>Cracked Pepper</span></a><br />
<div>
<div>
<b><font class="pricecolor colors_productprice"><span class=
"PageText_L483n">$11.00</span></font></b>
</div>
<img src="#" /></div>
</div>
Notes:
I can't change the HTML, it is automatically generated
The URL of the HTML includes "/Meats-s/", so it should be targeted by the second if conditional.
I can edit it with the same css selector (.colors_productname span) in a normal .css file, but this does not work.
bodybelow your jQuery? The<font>tag is not supported in HTML5.