【问题标题】:jquery, emulate anchor click with reljquery,用rel模拟锚点点击
【发布时间】:2012-09-30 04:53:04
【问题描述】:

有这张桌子

<table>
<tr id="1"><td>1</td></tr>
<tr id="1"><td>1</td></tr>
<tr id="2"><td>2</td></tr>
</table>

当用户单击表格行时,我需要模拟锚点单击,如下所示。

jQuery('tr').click(function(){

var id = jQuery(this).attr('id');

var anchor =  jQuery('<a />').attr({href:'index.php?id=' + id,rel:"{handler: 'iframe', size: {x: 800, y: 600}}"});

anchor.click();
});

我知道如何重定向,或者访问jQuery中的链接,这里的问题与锚的“rel”属性有关。

谢谢

【问题讨论】:

    标签: jquery anchor rel


    【解决方案1】:

    你需要将 a 标签附加到 dom 树上。

    anchor.appendTo('body').click();
    

    【讨论】:

    • 似乎 OP 需要 anchor.hide().appendTo('body').click().remove() 以防止其显示。也许remove 是不必要的......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    相关资源
    最近更新 更多