开发者

I need help fix this Javascript?

开发者 https://www.devze.com 2023-02-22 02:08 出处:网络
This JavaScript and also here is messing up and will not display it freezes up when I click the button it doesn\'t move it just stays there.

This JavaScript and also here is messing up and will not display it freezes up when I click the button it doesn't move it just stays there.

<script language="javascript" type="text/javascript"> 
function toggleSlideBox(x) {
        if ($('#'+x).is(":hidden")) {  // this line right here needs fixed 
            $(".editBox").slideUp(200);
            $('#'+x).slideDown(300);
        } else {
            $('#'+x).slideUp(300);
      开发者_运维技巧  }
}
</script>

Here is my website. If you register and go to both www.lazarusbenson.com/profile.php and also www.lazarusbenson.com/edit_profile.php and try to edit your profile or add a friend it messes up and does work right also my private messaging system is also messing up and keeps sending messages to my self and not the other users.


A great fix would be to use .SlideToogle() Instead. This will make sure that the code is nice and simple and will slide an ID/Class Up and Down:

<script language="javascript" type="text/javascript"> 
function toggleSlideBox(x) {
            $("#"+x).slideToogle(300);
      }
</script>


Try removing the '#'+

<script language="javascript" type="text/javascript"> 
function toggleSlideBox(x) {
        if ($(x).is(":hidden")) {  // this line right here needs fixed 
            $(".editBox").slideUp(200);
            $(x).slideDown(300);
        } else {
            $(x).slideUp(300);
        }
}
</script>


jQuery actually has a toggle function built in.

It's called jQuery().slideToogle

So just do

function toggleSlideDown(x) {
    $('#'+x).slideToggle(300);
}


So your error is:

$ is not defined [Break On This Error] if ($('#'+x).is(":hidden")) { 

which means you are not including jquery correctly in your html. Make sure you add this line in the (verbatim):

<SCRIPT type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></SCRIPT>          

If you are, the other option is that you are missing some closing parenthesis or bracket somewhere.

0

精彩评论

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