I dont have the best knowledge to js ot Jquery, so here goes:
I have some links, that returns false when clicked on.
But still i want to add a class to the element being clicked, because it is kind of a tab thingie in a div, so for usability..
At first when the page loads, i am doing something i think is a hopeless way? Because i want to add styles to the first tab, as it is showing info on page load:
window.onload = aktiv_sub;
function aktiv_sub() {
document.getElementById('sub_id_1').style.color='#FFF';
document.getElementById('sub_id_1').style.height='35px';
document.getElementById('sub_id_1').style.backgroundColor='#900';
document.getElementById('sub_id_4').style.color='#FFF';
document.getElementById('sub_id_4').style.height='35px';
document.getElementById('sub_id_4').style.backgroundColor='#096';
document.getElementById('sub_id_7').style.color='#FFF';
document.getElementById('sub_id_7').style.height='35px';
document.getElementById('sub_id_7').style.backgroundColor='#069';
document.getElementById('sub_id_10').style.color='#FFF';
document.getElementById('sub_id_10').style.height='35px';
document.getElementById('sub_id_10').style.backgroundColor='#664798';
}
This leaves me with a problem, when the other tabs are clicked:
I can add styles, but they do not get removed from the previously clicked link:
$(function() {
$(".sub").click(function() {
$(this).css("color", "white");
$(this).css("height", "35px");
$(this).css("background", "#990000");
// And then remove the styles, or write other styles to the links that are not active:
});
});
// I know i am hopeless // :-)
How can i turn this into a simple jquery function, that does all the magic??
Klemme