I am playing with a very simple jquery modal windows . It opens the modal windows by clicking on
<a href="#" id="clickMe">Click Me</a>
How can I make this javascript action by adding an attribute to the URL, eg index.php?q=clickMe or index.html#clickMe
I mean when visiting the webpage of index.html (with q=clickMe or #clickMe), loading the page with opened modal. In other words, the attribute plays the role of CLICK on id="clickMe" for jQuery.
You would need to handle the QueryString or URL Hash in the document.ready(). Here is an example of handling the hash #clickMe
$(document).ready(function () {
if (window.location.hash == "#clickMe") {
//open modal
}
});
first i would get a jquery plug in for reading querysting variables - like getUrlParam
then, you can do it in script
$(document).ready(function() {
if ($(document).getUrlParam("activate-click").length > 0) {
$("#clickMe").click();
}
});
尝试使用jquery.url
插件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.