jquery - display a div using javascript and onclick -


i've read lots of posts on i'm still struggling. i'm trying show , hide div class using simple java. can work in jsfiddle not on live site.

here's code i'm using. html first

<div id="mydiv1">     <div id="mydiv-container">         <div id="mydiv-content">             <h1>here's popup 1</h1>             <br>click link close.             <br>             <a href="#" onclick="show('mydiv2')">open 2</a>         </div>     </div> </div>  <div id="mydiv2"  style="display:none">     <div id="mydiv-container">         <div id="mydiv-content">             <h1>here's popup 2</h1>             <br>click link close.             <br>             <a href="#" onclick="hide('mydiv2')">close 2</a>         </div>     </div> </div> 

javascript:

function show(target) { document.getelementbyid(target).style.display = 'block'; }  function hide(target) { document.getelementbyid(target).style.display = 'none'; } 

can't workout why wont switch divs on live server.

i think problem on server ids i.e. mydiv1 , mydiv2 not unique. ids repeating.

check on server if ids not duplicating.

id should unique.

you can use web developer extension on firefox , chrome. duplicate ids on page

  1. install web developer on browser
  2. open options clicking on web developer icon
  3. click on information tab
  4. click on find duplicate ids

hope help.

to download toolbar:

chrome: https://chrome.google.com/webstore/detail/web-developer/bfbameneiokkgbdmiekhjnmfkcnldhhm?utm_source=chrome-app-launcher-info-dialog

firefox: https://addons.mozilla.org/en-us/firefox/addon/web-developer/?src=userprofile


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -