views:

408

answers:

1

How to change inline colorbox 'href' dynamic like i want when i click on a 'tr' colorbox take it 'title' to 'href' and show it like

<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>
+1  A: 

You can do this:

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

On row click, this takes the title attribute, uses it as an ID selector and shows the matching element. If you want to hide the others when this happens, give your divs a class like class="project" and just add a call to hide the test before showing, like this:

$("tr").click(function() {
   $(".project").hide();
   $("#" +  $(this).attr("title")).show();
});
Nick Craver
thank alot dude for early responce, i got the idea and tried this it workde for me .. thanx again<code>$("tr").colorbox({ width: "50%", inline: true, href: function() { var url = $(this).attr('title'); return '#' + url ; } }); </code>
Khawar