Well.. as you will see I'm totally new in JavaScript, and I'm trying to put the following (that works fine) into a function:
<script>var current_row;</script>
<div class="row_content" onclick="window.open('other_page.php); this.className='row_content_click'; if(current_row) current_row.className='row_content'; current_row=this;">
Now I would like to make a function so I will be able to reuse it.
This Is my own try that don't work:
<script>
function control_row(){
var current_row;
this.className='row_content_click';
if(current_row) {
current_row.className='row_content';
} else {
current_row=this;
}
}
</script>
<div class="row_content" onclick="control_row()">
How it should work:
- set a default class in the <div> tag.
- if the row is clicked change the class.
- if a other row is clicked change back to default class.
And.. please comment the function so I can understand what's happening!


Sign In
Create Account


Back to top









