我制作了一个小脚本,但我想知道我是否可以仅使用 jQuery 触发页面上的链接。
JS
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
$('a.more').each(function() {
var self = this;
if (vars['deeplink'] == 'true') {
/* this must trigger the link and that will trigger $(self).click */
}
$(self).click(function() {
var theid = self.href.split('#').pop();
var row = document.getElementById('info-art' + theid);
var now = typeof(row.style.display) != 'undefined' ? row.style.display : 'none';
$('tr.info').each(function() { this.style.display = 'none'; });
if (now == 'none') {
row.style.display = $.browser.msie ? 'block' : 'table-row';
}
});
});
HTML
<td><a class="more" href="#8714681006955">[+]</a></td>