Hide if dynamic text is empty - still no solution

I’m still searching for a solution to hide an element if there is no content found in that element.
I’m using Custom fields that are dynamically populating a custom post type via global block (not sure if I said that correctly).

But anyway, if nothing is entered into a CPT field, then I want that element hidden on the page. Here is the different snippets of code that I’ve tried to use in the JS area of the Global Block:

jQuery(document).ready(function($) {
if ( $(".x-quote-text").html() == “”){
$(".x-quote").addClass(“visuallyhidden”);
}
});

jQuery(document).ready(function($) {
str = $(’.x-quote-text’).text();
if($.trim(str) === “”) {
$( “.x-quote” ).empty();
}
});

jQuery(document).ready(function($) {
if ( $(".x-quote-text").text().length == 0 )
$(".x-quote").addClass(“visuallyhidden”);
}
});

jQuery(document).ready(function($) {
str = $(‘div.x-quote-text’).text();
if($.trim(str) === “”) {
$(‘blockquote.x-quote’).visuallyhidden();
}
});

And of course I added the CSS for the .visuallyhidden {display: none;}

None of this worked.

Any ideas?

Hello Jonathan,

Thanks for writing in! Please be understand that custom development is beyond the scope of our support. We only cater getting your site setup, bug fixes and minor cosmetic changes. Your modifications requires custom JS coding. You may need further help from a JS expert or 3rd party developer to be able to accomplish what you have in mind.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.