views:

25

answers:

2

If a checkbox is hidden using jquery .hide how to show it again if we know the value in the following case

    <input type="checkbox" value="1" name="m_q"/>
    <input type="checkbox" value="2" name="m_q"/>
    <input type="checkbox" value="3" name="m_q"/>
    <input type="checkbox" value="4" name="m_q"/>

So the check box with value 1 is hidden how to use .show using jquery

+3  A: 
$("input[value=1]").show();
dave thieben
Ah... the simplicity of jQuery :) +1 Great answer.
Doug Neiner
A: 

I wouldn't show/hide the checkboxes the way you are doing, but of course I am just guessing as what you actually want. I would just use one checkbox and simply update the value:

<input type="checkbox" value="4" name="m_q" id="m_q" />

Now, instead of hiding 4 and showing 1 just do this:

$("#m_q").val(1);

Or if you can't add the id:

$("input[name=m_q]").val(1);

Remember, "View Source" will not reveal the value change even if it is working.

Doug Neiner