tags:

views:

52

answers:

2

The code is :

$("#radioGroup").click(function()  {
    $("#groupSpan").css("display", "block");
    $("#advisorSpan").css("display", "none");
});

and for second button of radio group:

$("#radioAdvisor").click(function()  { 
  $("#groupSpan").css("display", "none");
  $("#advisorSpan").css("display", "block");
});

this works fine, well almost. If you scroll between clicking radio buttons, the span is displayed in the inccorect position - basically where it shoudl have been before scroll - looks well strange jsut appears over completely unrelated elements.

Please help?

+1  A: 
$("#radioGroup").click(function()  {
    $("#groupSpan").css("display", "inline");
    $("#advisorSpan").css("display", "none");
});

$("#radioAdvisor").click(function()  { 
  $("#groupSpan").css("display", "none");
  $("#advisorSpan").css("display", "inline");
});
Kai
+4  A: 

I would suggest using the shortcut methods. They usually display better.

$("#radioGroup").click(function()  {
    $("#groupSpan").show();
    $("#advisorSpan").hide();
});

$("#radioAdvisor").click(function()  { 
  $("#groupSpan").hide();
  $("#advisorSpan").show();
});
David Radcliffe
The matched elements will be revealed immediately, with no animation. This is roughly equivalent to calling .css('display', 'block'), except that the display property is restored to whatever it was initially. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.
RobertPitt