attila2452 Posted January 12, 2012 Share Posted January 12, 2012 Whats the best solution for completing this:http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.htmlthe website I'm working on.scroll down a bit and click the H4 there's a hidden content that slides out.but when multiple on page, it unfolds them all. whats my best option.the reason it opens both is because their both set to the same ID's. and i know that if i set all divs different ID's it will work. BUT what are my other options? are there any other options?here's the code:http://jsfiddle.net/attilahajzer/zx2dk/2/Please Help. Link to comment Share on other sites More sharing options...
dsonesuk Posted January 12, 2012 Share Posted January 12, 2012 Instead of targeting all .expand, target only the next sibling element with .expand $(document).ready(function(){ $(".click").click(function(){ $(this).next(".expand").slideToggle(); });}); Link to comment Share on other sites More sharing options...
attila2452 Posted January 13, 2012 Author Share Posted January 13, 2012 for some reason, it Opens, Closes, Opens, Closes then opens. same with closing. thats only if there's 2 on the page. if there's 1 on the page, it opens then closes. Link to comment Share on other sites More sharing options...
dsonesuk Posted January 13, 2012 Share Posted January 13, 2012 of course its going to jump up and down, IF you have 4-5 scripts carrying out the same function and producing the opposite result that the previous script applied. inline scripts found looking at page source Inline Script from http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.html$(document).ready(function() { $(".click").click(function() { $(".expand").slideToggle(); });});Inline Script from http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.html$(document).ready(function(){ $(".click").click(function(){ var target = $(this).parent().children(".expand"); $(target).slideToggle(); });});Inline Script from http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.html$(document).ready(function(){ $(".click").click(function(){ var target = $(this).parent().children(".expand"); $(target).slideToggle(); });});Inline Script from http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.html$(document).ready(function(){ $(".click").click(function(){ $(this).next(".expand").slideToggle(); });});Inline Script from http://app4.websitetonight.com/projects/2/3/9/4/2394058/Tools_for_Web_Success2.html$(document).ready(function(){ $(".click").click(function(){ var target = $(this).parent().children(".expand"); $(target).slideToggle(); });}); Link to comment Share on other sites More sharing options...
attila2452 Posted January 13, 2012 Author Share Posted January 13, 2012 The reason for this is that its on Website Tonight. and to input the script, you have to go to Insert > Script and when that opens up, it has this default text: <script type="text/javascript" src="http://www.a.com/Example1.js"></script><script type="text/javascript"> var JavaScriptExample = "Example 2";</script><script type="text/javascript" id="MyScript" defer="defer"> var JavaScriptExample = "Example 3";</script><p> <b>Script embedded in HTML</b> <script type="text/javascript"> var JavaScriptExample = "Example 4"; </script></p> i have to clear that, then input my script. then save and close. refresh the preview page. when i go back into the script page, the default code goes back where i originally put my script. There's now way of me to look at or edit my javascript code, only to re-submit it again. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.