How do I make this code more generic?
Hi all.
I have a table in which each cell forms a "button" to show/hide a div above it. Each "button" will show/hide a different div. The following code works, but how can i make it more generic?
- $(document).ready(
function() {
$('div.highlight-inner').hide(0);
$('td.col-1').hover(
function() {
$('div#highlight-1').slideToggle();
},
function() {
$('div#highlight-1').slideToggle();
}
);
$('td.col-2').hover(
function() {
$('div#highlight-2').slideToggle();
},
function() {
$('div#highlight-2').slideToggle();
}
);
}
);
Since the class numbers always match, is there a simple regex or some other method?
Thanks in advanced!
95slug