The below function does what it needs to - it checks if the div #searchBar is shown (it's a popup search box), and updates the placeholder attribute of #QuickSearchQuery accordingly.
<input type="search" name="keywords" placeholder="Search..." title="Search" id="QuickSearchQuery" />
<script type="text/javascript">
$(document).ready(function() {
if($('#searchBar').css('display') == 'block') {
$('#QuickSearchQuery').attr('placeholder','Additional Search Options');
} else {
$('#QuickSearchQuery').attr('placeholder','Search...');
}
});
</script>
The problem is that it only does this when the page loads. #searchBar's display can change from block to none based on the user clicking a different button, and when this is done it doesn't change the #QuickSearchQuery attribute.
I can't have the attribute change happen when that button is clicked, unfortunately, because there are other things which can cause #searchBar's display to change (clicking outside of #searchBar's div will set it to 'display: none').
I don't have a live example because the site isn't live yet, but mostly I just want to know if this kind of thing is possible.
Thank you!
$('selector:visible')to check if an element is visible.