Javascript the easy way
I have mentioned before that I don’t like Javascript. I’ll be honest about the reasons. Some may say it’s not safe or that the code is too permissive… whatever! I say I’m too lazy to learn it the way I like to learn a normal language, and I feel I have too many bits and bytes that I have to search for in an endless chaos to find the right docs.
Anyway, I finally found the easy way out. I had previously thought I did, when I found the prototype library. It was a nice one, and still is. However, it’s lacking a good documentation. But now, I found an even better solution: the jQuery library. You might take a look at their site, it’s quite loaded with features and docs, even plugins that help a lazy old programmer do new tricks.
One thing I made using jQuery is the following
-
-
<script type="text/javascript">
-
$(document).ready(function(){
-
$("a.morelnk").click(function(){$("#mo"+this.id).toggleClass("more");return true;});
-
$("#listing").corner();
-
});
-
</script>‘;
-
-
-
// snippet
-
if ( $row_num % 2 == 0 ) {
-
$table .= ‘<tr class="lineBottom" class="even" id="row_’.$row_num.‘">’;
-
} else {
-
$table .= ‘<tr class="lineBottom" id="row_’.$row_num.‘">’;
-
}
-
$table .= ‘<td>’.$row[‘ID’].‘</td>’;
-
$table .= ‘<td colspan=3 class="actions">’;
-
$table .= ‘<a href="#" class="morelnk" id="re_’.$row_num.‘" >…</a>’;
-
$table .= ‘</td>’;
-
$table .= ‘</tr>’;
-
$table .= ‘<tr class="more lineBottom bgGreen" id="more_’.$row_num.‘">’;
-
$table .= ‘<td class="lineRight">more information …</td>’;
-
$table .= ‘</tr>’;
-
-
$row_num += 1;
-
}
-
-
/* snippet */
-
.more {
-
display: none;
-
}
Post a comment
You must be logged in to post a comment.