开发者

Using jquery to conditionally display spans causes them to redisplay at wrong positions

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 ove开发者_运维技巧r completely unrelated elements.

Please help?


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();
});


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜