Function Optimization w/ jQuery
Hey,
I've been reading the jQuery documentation and trying to improve this function and its siblings, however I'm running into all sorts of syntactical problems when I make changes past this point. For example, I know there is a better way to write
-
document.getElementById(id).style.display = 'block';
and alternatives to the conditionals I used, but any attempts I make just seem to break it. Any insight into this issue would be appreciated, thanks!
-
showTab: function(o) {
if (currentTab) {
if ($('#currentTab')) {
document.getElementById(currentTab).style.display = 'none';
}
var b = currentLink.firstChild;
var ftype = b.src.substring(b.src.lastIndexOf('.'), b.src.length);
b.src = b.src.replace('_o' + ftype, ftype);
}
var id = o.href.substring(o.href.lastIndexOf('#') + 1);
currentTab = id;
currentLink = o;
if ($('#id')) {
document.getElementById(id).style.display = 'block';
}
o.firstChild.src = o.firstChild.src.replace(ftype, '_o' + ftype);
},