If URL not equal to specified URL then apply this jQuery? [closed]
if the current uURL is not same as specified then apply jQuery. BUT THIS WONT WORK
<script type="text/javascript">
var myurl = http://example.com/document.html;
var currenturl = window.location
if(myurl 开发者_如何学运维== currenturl) {
$("<span>url's match</span>").replaceAll("body"); // check replaceWith() examples
}
</script>
Also current URL can be a standard link http://example.com/
or as shown in example.
You need to quote your URL:
var myurl = http://site.com/document.html;
// Should be
var myurl = "http://site.com/document.html";
For best practice, don't omit the ;
here:
var currenturl = window.location
//---------------------------^^^^
You are missing quotes on the first line:
var myurl = "http://site.com/document.html";
And it should be != on the third line
精彩评论