toggling existing html markup, how can i do a function?
Hello, i use this piece of code to show/hide actual markup in a web page, but i want to do some function so when i call and pass a parameter it automatically sets the resulting behaviour. the thing is that i am new at jquery
- jQuery(document).ready(function($) {
$('.intertop ul.ultop .loginform a.login').click(function() {
if ($(this).hasClass('activo')) {
$(this).removeClass('activo').addClass('inactive');
$("#login-form").fadeOut().removeClass('activo');
} else {
$(this).addClass('activo').removeClass('inactive');
$("#login-form").fadeIn().addClass('activo');
}
});
})
is there a way in which i can example call function displaymarkup(what) with 2 choices a search form and a login form???
what should i study to do it right??
is there a clever way of doing this....
example of algorithm
- incoming data:target
- outcome: behaviour
- ----------------
- function calldisplay(target1:string,target2:string)
- $('target1').click(function() {
if ($(target1).hasClass('activo')) {
$(target1).removeClass('activo').addClass('inactive');
$(target2).fadeOut().removeClass('activo');
} else {
$(target1).addClass('activo').removeClass('inactive');
$(target2).fadeIn().addClass('activo');
}
});
})
- Incoming Data: what
- outcome: behaviour displaying one or two existent markup with displaynone
- -----------------------------------------------
- function showmarkup(whatbutton:string,whatblock:string)
- if what = search then
- calldisplay(searchbutton, search)
- if what = loginform then
- calldisplay(loginbutton,loginform)
really i know a little of jquery more or less its on the code above in pseudo code algorithm mixed with some actual code i am using.
i think i should have to wrap up everything on the jquery wrappers.
Thanks in advance for your help.
Salutations!!!