if (expr) {
$(seletor).prev().show();
} else {
$(seletor).next().show();
}

or the short sintax:

expr ? $('h2').prev().show() : $('h2').next().show();


MaurĂ­cio

-----Mensagem Original----- De: "Ami" <aminad...@gmail.com>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: segunda-feira, 19 de janeiro de 2009 01:12
Assunto: [jQuery] $(' Expert jQuery & JS synatx ' ).show



Sorry about my grammar, English isn't my lang.

I am trying to write code like that:
var expr=true,selector='div';
$(selector) (expr ? .next() : .before() ). show();

But it's not JS syntax. So how can I do it?

I know,that I can do it like that:
if (expr) $(selector)..before(),show() else $(selector).next().show()


But I am trying to find a solution, that return a jQuery object.

Thank you.


Reply via email to