Question

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>
Was it helpful?

Solution

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();
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top