Recently, I created a dynamic web page using jQuery which involves the hiding and showing of elements based on their classes.
For example:
<p class='lookup'>You can lookup all the values.</p>
If a user is unable to perform a lookup, I simply execute:
$('.lookup').hide();
using jQuery. Everything functions perfectly and runs smoothly.
Now, I am faced with the task of adding a simple remark in the HTML that varies depending on whether the class 'lookup' is visible or not. Essentially, implementing an if-else scenario.
<p class='lookup'>Show me when class lookup is visible</p>
<p ????>Show me when class lookup is not visible</p>
Is there a straightforward solution or workaround in HTML/CSS or even jQuery (outside of the existing script) that would display a paragraph whenever $('.lookup').hide();
is called and hide it when $('.lookup').show();
is executed?
I am eager to find out if there is a basic workaround for this dilemma, as currently, I am using an additional 'noLookup' class along with some added code in my existing jQuery script. It seems like there should be a simpler way to achieve this that I may have overlooked.