Reputation: 321
I am trying to check if a check box is checked and show an element on the page if it is checked.
This is my function:
function checkedTechSolutions(){
Y.one('#techsol input[type=checkbox]').on('change', function (e) {
var target = e.currentTarget,
techSBox = Y.one('#techsolutions');
if (target.get('checked')){
techSBox.show();
} else techSBox.hide();
}
}
This is my css:
#techsolutions {width: 380px; height: 100px; background-color:#cee4f2; display: none;}
#techsolutions .box {text-align: center;}
This is my html:
<div id="techsolutions">
<div class=box>
<label for="TypeOfTS">Tech Solutions: </label>
<select name="techSolutionsDrop">
<option value="techServices">Choose your services </option>
</select>
</div>
</div>
Upvotes: 1
Views: 455
Reputation: 8845
Some notes:
#techsol
checkedTechSolutions
ever called? You do not need a document ready type event to attach a listener to a checkbox when using YUI.Take a look at the full solution in this jsfiddle
Upvotes: 1