Home Hide link if href is blank, and then display a different button?
Reply: 0

Hide link if href is blank, and then display a different button?

user851
1#
user851 Published in June 23, 2018, 4:24 am

I have a link and div within each of my list items. If the link HAS an href then I want to make sure the div is hidden within its list item and the link appear just normal.

However if the link DOES NOT have a href (e.g. href=""), then I want to add the class .show to the div so I can show it. I also want to hide the link at the same time.

Or is there a better way to do this? Thanks

<style>
  .nolinkdiv { display:none; }
  .show { display:block!important; }
</style>

<ul>
  <li>
     <a href="/register.html">Register</a>
     <div class="nolinkdiv">Register Coming Soon</div>
  </li>
  <li>
     <a href="">Register</a>
     <div class="nolinkdiv">Register Coming Soon</div>
  </li>
</ul>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319772 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO