Show/hide script not working
3 posters
Page 1 of 1
Show/hide script not working
Technical Details
Forum version : #phpBB2
Position : Founder
Concerned browser(s) : Google Chrome
Who the problem concerns : Yourself
Forum link : ( link is hidden, you must reply to see )
Description of problem
Hi! My problem is (as topic said script I try to use on my forum. It's not workin of course.Here's my script
- Code:
$(document).ready(function(){
$("div.dropdown-link").click(function(e) {
e.preventDefault();
var $div = $(this).next('.dropdown-container');
$(".dropdown-container").not($div).hide();
if ($div.is(":visible")) {
$div.hide()
} else {
$div.show();
}
});
$(document).click(function(e){
var p = $(e.target).closest('.dropdown').length
if (!p) {
$(".dropdown-container").hide();
}
});
});
- Code:
<div class="dropdown"><div class="dropdown-link">Options</div><div class="dropdown-container" style="display: none;">Some text here</div></div><div class="dropdown"><div class="dropdown-link" >Options</div><div class="dropdown-container" style="display: none;">Some text here</div></div><div class="dropdown"><div class="dropdown-link">Options</div><div class="dropdown-container" style="display: none;">More words etc.</div></div>
So, I'd like to know why it's not working on my forum while it's doing on jsfiddle. And it'd be great to get any tips what I can do to achieve similar effect.
Re: Show/hide script not working
Hi @mremmet,
When scripts are added to JS codes management they're automatically minified to remove a majority of the whitespace. Sometimes this can cause errors with scripts if they're missing a semicolon or two.
I checked over the script and a semicolon is missing after this statement :
Add a semicolon after that and it should work.
When scripts are added to JS codes management they're automatically minified to remove a majority of the whitespace. Sometimes this can cause errors with scripts if they're missing a semicolon or two.
I checked over the script and a semicolon is missing after this statement :
- Code:
var p = $(e.target).closest('.dropdown').length
Add a semicolon after that and it should work.
Re: Show/hide script not working
Topic solved and archived
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Hide effect for similar topics script
» Script doesn't show image for users
» Show/Hide Widgets Script at both sides
» Custom form Tutorial - Script not working
» Hide some topics via script?
» Script doesn't show image for users
» Show/Hide Widgets Script at both sides
» Custom form Tutorial - Script not working
» Hide some topics via script?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum