[jQuery] Displaying HTML via checkbox
I'm probably missing something very simple here... I have a checkbox
with the ID of (#pkg). When checked it displays an HTML text field
(see if statement). When unchecked, it goes away (look at the else
statement) using CSS (display: none). The problem I'm running into,
if I re-check the checkbox, it does nothing. It does not display the
HTML text field. I would like to redisplay the HTML -- first part of
the if statement. What am I doing wrong here? Any help would be
great. Code is below. Thanks in advance - CH
$(document).ready(function() {
$("#pkg").change(function() {
showGrpName();
});
function showGrpName() {
if($("input#pkg").attr("checked")) {
$("#groupBox").html("<p class='p_name'><img src='images/background/
rt_arrow.gif' alt='group' width='10' height='8' />Group Name <input
type='text' name='package_name' />");
} else {
$("#groupBox").css("display", "none");
}
}
});