Javascript, hide paragraph

Categories: Development, Troubleshoot



While I was developing a new app for use here at work. I tried to use javascript to hide an element and all of its contents.

JAVASCRIPT:
  1. function show_new(id_name)
  2. {
  3.     $('#category').hide();
  4.    
  5.     return false;
  6. }

To hide this html stuffs

HTML:
  1. <p id="category">
  2.             <label>Category</label><br />
  3.             </p><div class="select">
  4.                 <select class="medium" name="category">
  5.                     <option>-Select-</option>
  6.                 </select>
  7.                 <span class="moreinfo">Or add a <a onclick="return show_new('category');" href="#">test<span class="red">NEW CATEGORY</span></a> </span>
  8.             </div>
  9.             <div class="new">
  10.                 <input type="text" name="category" />
  11.                 <span class="moreinfo">Or add a <a href="#"><span class="red">NEW CATEGORY</span></a> </span>
  12.             </div>
  13.       <p>&nbsp;</p>

When I click on the link "NEW CATEGORY", it executes the javascript function but the only thing that it hides is the label. Everything else stays. I thought there was a duplicate or some shit, but no, there's none. Then I remembered that you cannot put block elements inside an inline element (thanks to weekly check using w3cvalidator on my blog).

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.