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 id
s i.e. mydiv1
, mydiv2
not unique. id
s repeating.
check on server if id
s not duplicating.
id should unique.
you can use web developer
extension on firefox , chrome. duplicate id
s on page
- install
web developer
on browser - open options clicking on
web developer
icon - click on
information
tab - click on
find duplicate ids
hope help.
to download toolbar:
firefox: https://addons.mozilla.org/en-us/firefox/addon/web-developer/?src=userprofile
Comments
Post a Comment