0

I'm currently using a service for autocompleting my search boxes. However, for all the autocompleted results that show up, there's always a <div> ad on the bottom following the <li>s. Something like this:

<ul>
<li class="menu-item""></li>
<li class="menu-item""></li>
<li class="menu-item""></li>
<div style="text-align:center;border-top:1px solid black;"></div>
<a href="http://www.ad.com" target="_blank">ad</a>
</ul>

However, this is loaded dynamically using JS so I don't know how I would write jQuery to hide() it. Is there a way I could dynamically hide it when someone does a search?

2
  • For starters, your HTML is invalid. Commented Mar 14, 2013 at 19:29
  • sorry I forgot to paste the end Commented Mar 14, 2013 at 19:30

2 Answers 2

2

You could do something like this in your CSS:

ul>* {display:none}
ul>li {display:block}

After all, it is only valid for <ul> elements to have <li> children, so you should be able to hide everything else as invalid.

Sign up to request clarification or add additional context in comments.

4 Comments

will this work for nodes that are not present in the initial load of the DOM? the li's and div are generated dynamically when someone types a search term, so it doesn't exist in the initial load
@Edmund yes, it will be applied as and when the nodes load on page.
is there a way to make this CSS line load after all the other CSS files in this app? my line is being overridden by the Ad company's CSS.
Add !important before each } to make it override the ad company's CSS. Or you could just find a solution that doesn't involve an ad ;)
0

If you are sure of the structure, you can always address it in jquery as

$("ul").find("a,div").hide()

Best would be of course css, as Kolink answered.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.