Change the opecity decrease and increase on each click of button


Viewing 1 post (of 1 total)
  • Author
  • #4924

    I have a div element as:

    <div id="divImage" class="opdiv" />
    <input id="ChangeOp" value="Set fade" />

    My problem is that the opacity of the divImage should be reset (increase or decrease .1 ) on the click of button. for example first time when user click on the button the opacity should be .9 and on the second click it should be .8 and so on..When it goes to 0 then it should be increase by .1.

    I have tried the javascript code for doing this but fails

    var opacity;
    opacity= 1;
     $('#ChangeOp').each(function() {
            $('#divImage").css('opacity', opacity);
      opacity = opacity - .1;

    But when the opacity becomes 0 then what how to increase. Please help to complete the above code.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.