Toggle container when external link is clicked
I used the toggle tutorial from here http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial and came up with this website.
There is only 1 toggle link on the website.
My problem is, I have a html newsletter where a link needs to be placed and when it is clicked, it will go to the website and automatic开发者_JS百科ally focuses on the toggle link. The toggle link also should be automatically opened without clicking on it.
How can I achieve this?
The link in your HTML newsletter should contain a query string or hash on the link, like so:
http://publicis-malaysia.com/ipad2/index.html?autofocus
or
http://publicis-malaysia.com/ipad2/index.html#autofocus
And then you can detect this in jQuery code:
if (location.hash.indexOf('autofocus') > -1) {
$('.trigger').click();
}
This will check for 'autofocus' in the document hash when the page is opened, and then click the element. If you want to use the querystring ("?autofocus"), you should use 'search' instead of 'hash' in the first line of the example code.
You can put the code right after the code you took from the tutorial, in the script block in the head.
精彩评论