指向链接时,jQuery应显示默认隐藏的div [英] jQuery when pointed to a link should show a div that's hidden by default
问题描述
我有一个页面,其中有几个div默认隐藏。我希望能够将用户指向显示div的链接。
ex。 https://app.emailsmsmarketing.com/login
用户可以点击登录隐藏登录div并显示寄存器div。我想要完成的是基本上添加一个链接到主站点,用户可以在其中默认访问注册表单(仅限使用jQuery)。
恩。 https://app.emailsmsmarketing.com/login#!register (或类似的东西)
基本上我问的是:
a)是可以做到的
b)如果是这样,怎么样?
我不确定这对任何人都有意义。感谢您提供的任何帮助。
您可能正在寻找: pre> var myUrl = document.location.toString();
if(myUrl.match('#')){// URL包含一个锚点
var myAnchor ='#'+ myUrl.split('#')[1];
$('#login')。hide();
$('#register')。show();
}
I have a page where there are a few divs hidden by default. I would like to be able to point users to a link where it would show the divs.
ex. https://app.emailsmsmarketing.com/login
Users are able to click "Register" which hides the login div and shows the register div. What I'm trying to accomplish is basically adding a link to the main site from where users will be able to access the registration form by default (using jQuery only).
ex. https://app.emailsmsmarketing.com/login#!register (or something like that)
Basically what I'm asking is:
a) is is possible to do this
b) if so, how?
I'm not sure if this makes sense to anyone. I appreciate any help provided.
You probably looking for this: Anchor-based URL navigation with jQuery
var myUrl = document.location.toString();
if (myUrl.match('#')) { // the URL contains an anchor
var myAnchor = '#' + myUrl.split('#')[1];
$('#login').hide();
$('#register').show();
}
这篇关于指向链接时,jQuery应显示默认隐藏的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!