I have the following query code:
function selectTag(id) {
var input = 'input#tag_' + id;
var span = '#span_' + id;
if ($(input).is(':checked') && $(span).hasClass('selected')) {
$(span).removeClass('selected');
$(input).prop('checked', false);
}
else {
$(span).addClass('selected');
$(input).prop('checked', true);
}
}
and the last part of the conditional is not executing. The check boxes are not being checked or unchecked.
Here is the html.
<?php foreach ($this->tags as $uri=>$tag){?>
<input type="checkbox" name="tags[]" style="display: none;" value="<?php echo $uri;?>" id="tag_<?php echo $uri;?>" <?php echo isset($args['tags']) && in_array($uri, $args['tags'])?'checked="checked"':'';?> />
<span onclick="selectTag(<?php echo $uri;?>)" id="span_<?php echo $uri;?>" for="create_<?php echo $uri;?>" class="tag <?php echo isset($args['tags']) && in_array($uri, $args['tags'])?'selected':'';?>"><?php echo str_replace(' ', ' ', $tag);?></span>
<?php }?>