Skip to content

Instantly share code, notes, and snippets.

@elias1435
Created January 2, 2023 09:46
Show Gist options
  • Save elias1435/aff5b7324ade3eb53710a228cf28a61b to your computer and use it in GitHub Desktop.
Save elias1435/aff5b7324ade3eb53710a228cf28a61b to your computer and use it in GitHub Desktop.
How to check if the URL contains a given string?
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (window.location.href.indexOf("checkout/?add-to-cart=1375&quantity=1") > -1) {
titleClass = document.querySelector(".find_class_to_add_new_class");
titleClass.classList.add("display-none-info");
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment