开发者

Javascript issue

I have a question regarding my button disappear

I've put an image as my button

<div id="button1">
   <a href="javascript:example_animate('-=200px')">
      <img src="images/button1.jpeg">
   </a>
</div>

that is animated with this function

<script language=开发者_如何学Python"javascript">
function example_animate(px) {
    $('#content2').animate({
        'marginTop' : px
    });
}
</script>

and i can't get it disappear after doing this function with this script

<script language="javascript">
$("#button1").click(function () {
   this.visible = false;
});
</script>

please help!


since you're already using jquery , just do

$("#button1").hide();

to hide the button. http://api.jquery.com/hide/

What you should have done to hide it the DOM way was to either set element.style.visibility='hidden';

OR

element.style.display='none';

Both calls will hide the element , but changing the visibility means the element will still occupy the screen space.


Instead of:

this.visible = false;

try:

this.style.display = "none";


Try this:

$("#button1").click(function () {
    this.style.display = "none";
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜