Mixing Javascript and jQuery? -


main question: possible use javascript conditional , use jquery code?

here non-working example:

<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> 

the javascript conditional provided ecommerce platform (volusion) target category pages (the jquery doing). asked them if javascript code still work given urls dont include "/searchresults.asp" (one of them "/meats-s/3393.htm"), assured me should still work.

secondary question: "location.pathname.indexof" lines do?

jquery , javascript not separate languages. jquery library written in javascript, valid jquery statement valid javascript statement.

q2: location.pathname path of url after domain name.

e.g http://www.google.com/s/goo.html -> pathname return s/goo.html

so if condition trying find out if string contains substring "-s".


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -