【问题标题】:how to give dynamic variable for href attribute inline colorbox如何为href属性内联颜色框提供动态变量
【发布时间】:2011-02-01 17:09:43
【问题描述】:

如何更改内联颜色框“href”动态 就像我想要的一样,当我单击“tr”颜色框时,将其“标题”改为“href” 并展示它 喜欢

<table>
    <tr title="project1">
        <td></td>
    </tr>
    <tr title="project2">
        <td></td>
    </tr>
</table>
<div id="project1" style="display:none">this is about project one</div>
<div id="project2" style="display:none">this is about project two </div>

【问题讨论】:

    标签: jquery dynamic inline href colorbox


    【解决方案1】:

    你可以这样做:

    $("tr").click(function() {
       $("#" +  $(this).attr("title")).show();
    });
    

    在行点击时,它采用 title 属性,将其用作ID 选择器并显示匹配的元素。如果您想在发生这种情况时隐藏其他人,请给您的 div 提供一个类似 class="project" 的类,然后在显示之前添加一个隐藏测试的调用,如下所示:

    $("tr").click(function() {
       $(".project").hide();
       $("#" +  $(this).attr("title")).show();
    });
    

    【讨论】:

    • 非常感谢老兄的早期反应,我明白了这个想法并尝试了这个它对我有用..thanx 再次 $("tr").colorbox({ width: "50%",内联:true,href:function() { var url = $(this).attr('title'); return '#' + url ; } });
    猜你喜欢
    • 1970-01-01
    • 2020-08-15
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 2012-03-26
    • 1970-01-01
    • 2015-07-16
    • 2017-03-24
    相关资源
    最近更新 更多