使用单选按钮显示隐藏元素(表单)

时间:2016-10-06 09:18:46

标签: jquery radio-button html-form

我正在尝试使用收音机显示和隐藏form元素。我做了一个尝试,但仍然无效。谁能给我一些指导?

$('input[name="radio-3"]').click(function(){
    if ($(this).attr("id") == "radio-3") {
        $("details").show();
    } else {
        $("details").hide();
    }
});
<div id = "radioButton">
    <input type="radio" name="radio-1" id="radio-3">
    <label for="radio-3">I want you to create my artwork</label>
</div>
<div id="details">
    <form>
        Please leave your name:<br>
        <input type="text" name="firstname"><br>

        Email:<br>
        <input type ="email" name ="email"><br>
</div>
<div id="detailsSecond">
    Please leave us a description of your artwork brief: <br>
    <textarea name = "textarea" rows="10" cols="50">Write something here</textarea>
</form>
</div>

0 个答案:

没有答案