In my options panel I have a section where the user can enter their Twitter username. Currently if the value for that field is empty, the Twitter icon disappears on my website, which is good as it means the div class has been successfully hidden. However, when I enter a username in the field, the div class still stays hidden.
This is the jQuery I have at the moment:
<script type="text/javascript">
$(document).ready(function() {
if($('mytheme_twitter:empty')){$('.twitter').hide();}
});
</script>
I think something must be missing from it. Do I need to add another function? If so, where do I put it? I’m a bit of a jQuery noob.
Firstly :empty is the wrong selector for this use case.
Change you logic to check if the value of the imput is empty.
You need to write up a change event to handle that case..
//