JQ獲取URL中是否含有某個字符的話,對頁面進行某種操作


一、//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" }); }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM