首页 > 技术文章 > JQ获取URL中是否含有某个字符的话,对页面进行某种操作

fkcqwq 2017-05-27 18:52 原文

一、//JQ获取URL中是否含有某个字符的话,对页面进行某种操作
例:如果URL中含有xia的字符,就在页面引入一个css
var str=window.location.href; //获取地址栏URL if(str.indexOf("xia")>-1){ //如果URL中含有xia就对页面进行某种操作 $("head").append("
<link>"); var toolbarCss = $("head").children(":last"); toolbarCss.attr({ rel: "stylesheet", type: "text/css", href: "http://html.huiyiguanjia.com/custom/201803FuneralInterment/css/index-fsy.css" }); }

 

 

推荐阅读