1

Once my eraser is clicked, I want the color to hidden or shouldn't show its dropdown elements. I tried..here is my partial code.

   $('#chooseEraser').mousedown(function(e){
        curTool = "eraser";
        checkEraser = true;
        $('#color').remove();
    });

Here is the link

6
  • As of now, nothing happens if I press "Color" there... Was it meant to be like that ? Commented Mar 6, 2011 at 5:12
  • What's wrong with $('#color').css("visibility","hidden");? Commented Mar 6, 2011 at 5:14
  • @use hide() instead of .remove as it removes the html completly. Commented Mar 6, 2011 at 5:15
  • I see no element with an id of chooseEraser in your HTML. Commented Mar 6, 2011 at 5:16
  • As of now, after I click "eraser" ..I still see the "color" even after adding $('color).hide(); Commented Mar 6, 2011 at 5:23

2 Answers 2

1

I just tried $("#color").hide(); and it did work on your page.

Your code is just missing the # symbol.

Also, try using jQuery instead of just $: jQuery("#color").hide();. The $ shortcut might not always be available (redefined in some scopes).

Sign up to request clarification or add additional context in comments.

3 Comments

I didn't miss #..I see it there. Anyways its not working for me..I didn't understand
dragonfly.zymichost.com/Canvas/js/canvas6.js is missing the # on line 111.
Nevermind. Neat experiment that you're doing with the canvas element, by the way.
1

I don't exactly understand your question and I don't think you're doing anything wrong in your code. But just for clarification, there are a few ways that you can hide/disable elements using jQuery:

This will hide the element but the element will continue to take up space on the page:

$('#colorId').css('visibility', 'hidden');

This will hide the element and no longer occupy any space on the page:

$('#colorId').hide();

This will disable the element:

$('#colorId').attr('disabled', 'disabled');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.