How do I get the dots to go away? [closed] - javascript
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
This is a pre made website. I am working on it, and I am okay with CSS and HTML, but I don't have much experience with Java. I think that the problem is with Java. I would really like the dots to not be there where the list items just rotate without the dots appearing below.
/*! http://responsiveslides.com v1.54 by #viljamis */
(function(c,I,B){c.fn.responsiveSlides=function(l){var a=c.extend({auto:!0,speed:500,timeout:4E3,pager:!1,nav:!1,random:!1,pause:!1,pauseControls:!0,prevText:"Previous",nextText:"Next",maxwidth:"",navContainer:"",manualControls:"",namespace:"rslides",before:c.noop,after:c.noop},l);return this.each(function(){B++;var f=c(this),s,r,t,m,p,q,n=0,e=f.children(),C=e.size(),h=parseFloat(a.speed),D=parseFloat(a.timeout),u=parseFloat(a.maxwidth),g=a.namespace,d=g+B,E=g+"_nav "+d+"_nav",v=g+"_here",j=d+"_on",
w=d+"_s",k=c("<ul class='"+g+"_tabs "+d+"_tabs' />"),x={"float":"left",position:"relative",opacity:1,zIndex:2},y={"float":"none",position:"absolute",opacity:0,zIndex:1},F=function(){var b=(document.body||document.documentElement).style,a="transition";if("string"===typeof b[a])return!0;s=["Moz","Webkit","Khtml","O","ms"];var a=a.charAt(0).toUpperCase()+a.substr(1),c;for(c=0;c<s.length;c++)if("string"===typeof b[s[c]+a])return!0;return!1}(),z=function(b){a.before(b);F?(e.removeClass(j).css(y).eq(b).addClass(j).css(x),
n=b,setTimeout(function(){a.after(b)},h)):e.stop().fadeOut(h,function(){c(this).removeClass(j).css(y).css("opacity",1)}).eq(b).fadeIn(h,function(){c(this).addClass(j).css(x);a.after(b);n=b})};a.random&&(e.sort(function(){return Math.round(Math.random())-0.5}),f.empty().append(e));e.each(function(a){this.id=w+a});f.addClass(g+" "+d);l&&l.maxwidth&&f.css("max-width",u);e.hide().css(y).eq(0).addClass(j).css(x).show();F&&e.show().css({"-webkit-transition":"opacity "+h+"ms ease-in-out","-moz-transition":"opacity "+
h+"ms ease-in-out","-o-transition":"opacity "+h+"ms ease-in-out",transition:"opacity "+h+"ms ease-in-out"});if(1<e.size()){if(D<h+100)return;if(a.pager&&!a.manualControls){var A=[];e.each(function(a){a+=1;A+="<li><a href='#' class='"+w+a+"'>"+a+"</a></li>"});k.append(A);l.navContainer?c(a.navContainer).append(k):f.after(k)}a.manualControls&&(k=c(a.manualControls),k.addClass(g+"_tabs "+d+"_tabs"));(a.pager||a.manualControls)&&k.find("li").each(function(a){c(this).addClass(w+(a+1))});if(a.pager||a.manualControls)q=
k.find("a"),r=function(a){q.closest("li").removeClass(v).eq(a).addClass(v)};a.auto&&(t=function(){p=setInterval(function(){e.stop(!0,!0);var b=n+1<C?n+1:0;(a.pager||a.manualControls)&&r(b);z(b)},D)},t());m=function(){a.auto&&(clearInterval(p),t())};a.pause&&f.hover(function(){clearInterval(p)},function(){m()});if(a.pager||a.manualControls)q.bind("click",function(b){b.preventDefault();a.pauseControls||m();b=q.index(this);n===b||c("."+j).queue("fx").length||(r(b),z(b))}).eq(0).closest("li").addClass(v),
a.pauseControls&&q.hover(function(){clearInterval(p)},function(){m()});if(a.nav){g="<a href='#' class='"+E+" prev'>"+a.prevText+"</a><a href='#' class='"+E+" next'>"+a.nextText+"</a>";l.navContainer?c(a.navContainer).append(g):f.after(g);var d=c("."+d+"_nav"),G=d.filter(".prev");d.bind("click",function(b){b.preventDefault();b=c("."+j);if(!b.queue("fx").length){var d=e.index(b);b=d-1;d=d+1<C?n+1:0;z(c(this)[0]===G[0]?b:d);if(a.pager||a.manualControls)r(c(this)[0]===G[0]?b:d);a.pauseControls||m()}});
a.pauseControls&&d.hover(function(){clearInterval(p)},function(){m()})}}if("undefined"===typeof document.body.style.maxWidth&&l.maxwidth){var H=function(){f.css("width","100%");f.width()>u&&f.css("width",u)};H();c(I).bind("resize",function(){H()})}})}})(jQuery,this,0);
#slider3,#slider4 {
box-shadow: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
margin: 0 auto;
}
.rslides_tabs {
list-style: none;
padding: 0;
background: rgba(0,0,0,.25);
box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);
-moz-box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);
font-size: 18px;
list-style: none;
margin: 0 auto 50px;
max-width: 540px;
padding: 10px 0;
text-align: center;
width: 100%;
}
.rslides_tabs li {
display: inline;
margin-right: 1px;
}
.rslides_tabs a {
width: auto;
line-height: 20px;
padding: 9px 20px;
height: auto;
background: transparent;
display: inline;
}
.rslides_tabs li:first-child {
margin-left: 0;
}
.rslides_tabs .rslides_here a {
background: rgba(255,255,255,.1);
color: #fff;
font-weight: bold;
}
.events {
list-style: none;
}
.callbacks_container {
position: relative;
width: 100%;
}
.callbacks {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.callbacks li {
position: absolute;
width: 100%;
left: 0;
top: 0;
}
.callbacks img {
position: relative;
z-index: 1;
height: auto;
border: 0;
}
.callbacks .caption {
display: block;
position: absolute;
z-index: 2;
font-size: 20px;
text-shadow: none;
color: #fff;
left: 0;
right: 0;
padding: 10px 20px;
margin: 0;
max-width: none;
top: 10%;
text-align: center;
}
.callbacks_nav {
position: absolute;
-webkit-tap-highlight-color: rgba(0,0,0,0);
top: 61%;
left: 0;
opacity: 0.7;
z-index: 3;
text-indent: -9999px;
overflow: hidden;
text-decoration: none;
height: 62px;
width: 45px;
margin-top: -65px;
}
.callbacks_nav:active {
opacity: 1.0;
}
a.callbacks_nav.callbacks1_nav.prev {
background: transparent url("../images/themes.png") no-repeat 0px 0px;
left: -3.1%;
}
.callbacks_nav.next {
background: transparent url("../images/themes.png") no-repeat -46px 0px;
left: 100%;
}
#slider3-pager a,#slider4-pager a {
display: inline-block;
}
#slider3-pager span,#slider4-pager span{
}
#slider3-pager span,#slider4-pager span{
width:100px;
height:15px;
background:#fff;
display:inline-block;
border-radius:30em;
opacity:0.6;
}
#slider3-pager .rslides_here a ,#slider4-pager .rslides_here a {
background: #FFF;
border-radius:30em;
opacity:1;
}
#slider3-pager a ,#slider4-pager a {
padding: 0;
}
#slider3-pager li, #slider4-pager li{
display:inline-block;
}
.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li{
position: relative;
display: block;
}
<div class="banner-info">
<script src="js/responsiveslides.min.js"></script>
<script>
// You can also use "$(window).load(function() {"
$(function () {
// Slideshow 4
$("#slider3").responsiveSlides({
auto: true,
pager: true,
nav: false,
speed: 500,
namespace: "callbacks",
before: function () {
$('.events').append("<li>before event fired.</li>");
},
after: function () {
$('.events').append("<li>after event fired.</li>");
}
});
});
</script>
<div id="top" class="callbacks_container">
<ol class="rslides" id="slider3">
<li>
<div class="banner-text">
<h3>Strategic Benefits Design</h3>
<h4>
We simplify HR so you can focus on your business!</h4>
</div>
</li>
<li>
<div class="banner-text">
<h3>Strategic Benefits Design</h3>
<h4>We are committed to helping grow your business!</h4>
</div>
</li>
<li>
<div class="banner-text">
<h3>Strategic Benefits Design</h3>
<h4>We give you exactly what you need!</h4>
</div>
</li>
</ol>
</div>
</div>
You got the following code in your HTML file:
$("#slider3").responsiveSlides({
auto: true,
pager: true,
nav: false,
speed: 500,
namespace: "callbacks",
before: function () {
Change pager: true, to pager: false, and see if it works. I don't know if it will for sure, but this would be the first thing I would try after seeing the ResponsiveSlides.js website.
Related
terms&service onload popup [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year. Improve this question I need a terms and service popup as soon as the page loads how can I do that with html, javascript , css . please help.so basically as soon as I load to my website there is a pop up with terms and service which I have ready .
based on this reference - codepen ref $(function() { var overlay = $('<div id="overlay"></div>'); overlay.show(); overlay.appendTo(document.body); $('.popup-onload').show(); $('.close').click(function() { $('.popup-onload').hide(); overlay.appendTo(document.body).remove(); return false; }); $('.x').click(function() { $('.popup').hide(); overlay.appendTo(document.body).remove(); return false; }); }); #overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; filter: alpha(opacity=70); -moz-opacity: 0.7; -khtml-opacity: 0.7; opacity: 0.7; z-index: 100; display: none; } .cnt223 a { text-decoration: none; } .popup-onload { width: 100%; margin: 0 auto; display: none; position: fixed; z-index: 101; } .cnt223 { min-width: 600px; width: 600px; min-height: 150px; margin: 100px auto; background: #f3f3f3; position: relative; z-index: 103; padding: 15px 35px; border-radius: 5px; box-shadow: 0 2px 5px #000; } .cnt223 p { clear: both; color: #555555; /* text-align: justify; */ font-size: 20px; font-family: sans-serif; } .cnt223 p a { color: #d91900; font-weight: bold; } .cnt223 .x { float: right; height: 35px; left: 22px; position: relative; top: -25px; width: 34px; } .cnt223 .x:hover { cursor: pointer; } <script src="https://code.jquery.com/jquery-1.8.2.js"></script> <div class='popup-onload'> <div class='cnt223'> <p> Terms and conditions <br/> <br/> <a href='' class='close'>Close</a> </p> </div> </div>
Create an HTML input text element with debounced on input callback
I have a JavaScript application where users can search for places on a map. The input text provides autocomplete suggestions: as the user types, some suggestions appear at the bottom of the text input itself. I'm using a third party JavaScript autocomplete library which charge per user request. Unfortunately each keystroke counts as a single request since the library doesn't implement any debouncing when receiving the onInput callback from the input element. So the suggestions look snappy but at a cost of many user requests. What I'd like to do is to redefine the on input callback inside the input element to implement debouncing (let's say 500ms). Since the third party library accepts the JavaScript element itself, I cannot use an external debouncing mechanism: (probably the library detects the onInput message sent by the input element itself) var placesAutocomplete = places({ appId: 'xxxxxxxxxxx', apiKey: 'kkkkkkkkkk', container: document.querySelector('#inputelement'), // <- the library accepts the element itself, not an "on input" listener (which could be easily debounced by an external function) language: G_lang }); placesAutocomplete.on('change', function(res){ // user leaves the input text, set lat lon on my map (code not shown here on SO) var lat = res.suggestion.latlng.lat; var lon = res.suggestion.latlng.lng; finish(lat, lon); }); the debounce must be provided by the JavaScript element itself. So basically, the element should fire an onInput callback filtered by the debouncing mechanism. Is it possible to do so by using vanilla JavaScript only? EDIT Looks like someone tried to make a pull request for a debounce feature on the GitHub project page but got rejected: https://github.com/algolia/places/issues/281 and someone else forked the library and merged the pull request on its own fork -> https://github.com/AcuityScheduling/places/tree/feature/debounce
Using the official codepen, I made this hackish debounced version: var client = algoliasearch("latency", "6be0576ff61c053d5f9a3225e2a90f76") var index = client.initIndex('movies'); var myAutocomplete = autocomplete('#search-input', { hint: false }, [{ source: autocomplete.sources.hits(index, { hitsPerPage: 5 }), displayKey: 'title', templates: { suggestion: function(suggestion) { var sugTemplate = "<img src='" + suggestion.image + "'/><span>" + suggestion._highlightResult.title.value + "</span>" return sugTemplate; } } }]).on('autocomplete:selected', function(event, suggestion, dataset) { console.log(suggestion, dataset); }); document.querySelector(".searchbox [type='reset']").addEventListener("click", function() { document.querySelector(".aa-input").focus(); this.classList.add("hide"); myAutocomplete.autocomplete.setVal(""); }); document.querySelector("#debouncer").addEventListener("input", function() { var s = document.querySelector("#search-input"); s.value = this.value; clearTimeout(this.tick); this.tick = setTimeout(() => s.dispatchEvent(new KeyboardEvent('input')), 500); }); document.querySelector("#search-input").addEventListener("input", function() { var searchbox = document.querySelector(".aa-input"); var reset = document.querySelector(".searchbox [type='reset']"); if (searchbox.value.length === 0) { reset.classList.add("hide"); } else { reset.classList.remove('hide'); } }); body { padding: 60px; } .searchbox { display: inline-block; position: relative; width: 200px; height: 37px; white-space: nowrap; box-sizing: border-box; font-size: 13px; font-family: arial, sans-serif; } #debouncer { position: absolute; z-index: 1; box-sizing:border-box; padding: 0 30px 0 37px; width: 100%; height: 100%; vertical-align: middle; white-space: normal; font-size: inherit; -webkit-appearance: none; -moz-appearance: none; appearance: none; background: none; border:0; } .algolia-autocomplete { display: block; height: 100%; } .searchbox__wrapper { width: 100%; height: 100%; } .searchbox__input { display: inline-block; -webkit-transition: box-shadow .4s ease, background .4s ease; transition: box-shadow .4s ease, background .4s ease; border: 0; border-radius: 19px; box-shadow: inset 0 0 0 1px #D9D9D9; color:transparent; background: #FFFFFF; padding: 0; padding-right: 30px; padding-left: 37px; width: 100%; height: 100%; vertical-align: middle; white-space: normal; font-size: inherit; -webkit-appearance: none; -moz-appearance: none; appearance: none; } .searchbox__input::-webkit-search-decoration, .searchbox__input::-webkit-search-cancel-button, .searchbox__input::-webkit-search-results-button, .searchbox__input::-webkit-search-results-decoration { display: none; } #debouncer:hover ~ * .searchbox__input { box-shadow: inset 0 0 0 1px silver; } #debouncer:focus ~ * .searchbox__input, #debouncer:active ~ * .searchbox__input { outline: 0; box-shadow: inset 0 0 0 1px #4098CE; background: #FFFFFF; } #debouncer::-webkit-input-placeholder { color: #AAAAAA; } #debouncer::-moz-placeholder { color: #AAAAAA; } #debouncer:-ms-input-placeholder { color: #AAAAAA; } #debouncer::placeholder { color: #AAAAAA; } .searchbox__submit { position: absolute; z-index:2; top: 0; right: inherit; left: 0; margin: 0; border: 0; border-radius: 18px 0 0 18px; background-color: rgba(255, 255, 255, 0); padding: 0; width: 37px; height: 100%; vertical-align: middle; text-align: center; font-size: inherit; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .searchbox__submit::before { display: inline-block; margin-right: -4px; height: 100%; vertical-align: middle; content: ''; } .searchbox__submit:hover, .searchbox__submit:active { cursor: pointer; } .searchbox__submit:focus { outline: 0; } .searchbox__submit svg { width: 17px; height: 17px; vertical-align: middle; fill: #666666; } .searchbox__reset { position: absolute; z-index:2; top: 8px; right: 8px; margin: 0; border: 0; background: none; cursor: pointer; padding: 0; font-size: inherit; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; fill: rgba(0, 0, 0, 0.5); } .searchbox__reset.hide { display: none; } .searchbox__reset:focus { outline: 0; } .searchbox__reset svg { display: block; margin: 4px; width: 13px; height: 13px; } .searchbox__input:valid~.searchbox__reset { display: block; -webkit-animation-name: sbx-reset-in; animation-name: sbx-reset-in; -webkit-animation-duration: .15s; animation-duration: .15s; } #-webkit-keyframes sbx-reset-in { 0% { -webkit-transform: translate3d(-20%, 0, 0); transform: translate3d(-20%, 0, 0); opacity: 0; } 100% { -webkit-transform: none; transform: none; opacity: 1; } } #keyframes sbx-reset-in { 0% { -webkit-transform: translate3d(-20%, 0, 0); transform: translate3d(-20%, 0, 0); opacity: 0; } 100% { -webkit-transform: none; transform: none; opacity: 1; } } .aa-dropdown-menu { position: relative; top: -6px; border-radius: 3px; margin: 6px 0 0; padding: 0; text-align: left; height: auto; position: relative; background: transparent; border: none; width: 100%; left: 0 !important; box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1); } .aa-dropdown-menu:before { position: absolute; content: ''; width: 14px; height: 14px; background: #fff; z-index: 0; top: -7px; border-top: 1px solid #D9D9D9; border-right: 1px solid #D9D9D9; transform: rotate(-45deg); border-radius: 2px; z-index: 999; display: block; left: 24px; } .aa-dropdown-menu .aa-suggestions { position: relative; z-index: 1000; } .aa-dropdown-menu [class^="aa-dataset-"] { position: relative; border: solid 1px #D9D9D9; border-radius: 3px; overflow: auto; padding: 8px 8px 8px; } .aa-dropdown-menu * { box-sizing: border-box; } .aa-suggestion { font-size: 1.1em; padding: 4px 4px 0; display: block; width: 100%; height: 38px; clear: both; } .aa-suggestion span { white-space: nowrap!important; text-overflow: ellipsis; overflow: hidden; display: block; float: left; line-height: 2em; width: calc(100% - 30px); } .aa-suggestion.aa-cursor { background: #eee; } .aa-suggestion em { color: #4098CE; } .aa-suggestion img { float: left; vertical-align: middle; height: 30px; width: 20px; margin-right: 6px; } <script src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script> <script src="//cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script> <form novalidate="novalidate" onsubmit="return false;" class="searchbox"> <div role="search" class="searchbox__wrapper"> <input id="debouncer" type="text" name="search" autocomplete="off" placeholder="Search for a movie"> <input id="search-input" type="search" name="autocomplete" autocomplete="off" required="required" class="searchbox__input"> <button type="submit" title="Submit your search query." class="searchbox__submit"> <svg role="img" aria-label="Search"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-search-13"></use> </svg> </button> <button type="reset" title="Clear the search query." class="searchbox__reset hide"> <svg role="img" aria-label="Reset"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-clear-3"></use> </svg> </button> </div> </form> <div class="svg-icons" style="height: 0; width: 0; position: absolute; visibility: hidden"> <svg xmlns="http://www.w3.org/2000/svg"> <symbol id="sbx-icon-clear-3" viewBox="0 0 40 40"><path d="M16.228 20L1.886 5.657 0 3.772 3.772 0l1.885 1.886L20 16.228 34.343 1.886 36.228 0 40 3.772l-1.886 1.885L23.772 20l14.342 14.343L40 36.228 36.228 40l-1.885-1.886L20 23.772 5.657 38.114 3.772 40 0 36.228l1.886-1.885L16.228 20z" fill-rule="evenodd"/></symbol> <symbol id="sbx-icon-search-13" viewBox="0 0 40 40"><path d="M26.806 29.012a16.312 16.312 0 0 1-10.427 3.746C7.332 32.758 0 25.425 0 16.378 0 7.334 7.333 0 16.38 0c9.045 0 16.378 7.333 16.378 16.38 0 3.96-1.406 7.593-3.746 10.426L39.547 37.34c.607.608.61 1.59-.004 2.203a1.56 1.56 0 0 1-2.202.004L26.807 29.012zm-10.427.627c7.322 0 13.26-5.938 13.26-13.26 0-7.324-5.938-13.26-13.26-13.26-7.324 0-13.26 5.936-13.26 13.26 0 7.322 5.936 13.26 13.26 13.26z" fill-rule="evenodd"/></symbol> </svg> </div> This approach is hardly better than this autocomplete implementation itself.. Hope it may help.
I think I managed to find a very good solution. I forked the library and enabled the debounce feature (which was already there, only disabled for the autocomplete form). End result: 80% usage drop given a small autocomplete lag of 200ms, perfectly acceptable
Increasing CSS value instead of decreasing with jquery
I have a page that I need to convert to rtl. The active tab & tab arrow position doesn't match. I need to change the tab arrow position from TAB 1 to TAB 2 and vice versa. I already changed some js value but in vain HTML : <div class="container"> <div class="row"> <div class="col-md-12"> <div class="main-search-container"> <form class="main-search-form"> <div class="search-type"> <label class="active"><input class="first-tab" name="tab" checked="checked" type="radio">TEXT</label> <label><input name="tab" type="radio">TEXT</label> <label><input name="tab" type="radio">TEXT</label> <div class="search-type-arrow"></div> </div> <div class="main-search-box"> <div class="main-search-input larger-input"> </div> </div> </form> </div> </div> </div> </div> </div> CSS : body { direction:rtl; color: #707070; background-color: #cccccc; } .parallax { background-repeat: no-repeat; background-position: 50% 50%; position: relative; z-index: 99; } .parallax-overlay { position: absolute; top: 0; right: 0; width: 100%; height: 100%; z-index: 101; background-color: #333; opacity: 0.4; } .parallax-content { position: relative; z-index: 999; padding: 105px 0; } .main-search-container { transform: translate3d(0,-12px,0); } .main-search-form { width: 660px; display: block; margin: 0 auto; position: relative; margin-top: 35px; } .search-type { display: inline-block; padding-bottom: 35px; position: relative; } .search-type input[type="radio"] { display: none; } .search-type label { background-color: #fff; color: #333; cursor: pointer; display:inline-block; text-align: center; padding: 9px 18px; margin: 0 0 0 15px; float: right; transition: all 0.2s; border-radius: 3px; } .search-type label:hover, .search-type label.active { background-color: #66676b; color: #fff; } .search-type-arrow { width: 0; height: 0; border-right: 15px solid transparent; border-left: 15px solid transparent; border-bottom: 15px solid #fff; position: absolute; bottom: 0; right: 0; transform: translate3d(-3px,0,0); } .main-search-box { background-color: #fff; box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.12); padding: 30px; padding-bottom: 20px; margin-top: -9px; border-radius: 3px; } .main-search-box.no-shadow { box-shadow: none; padding: 0; margin: 0; } .search-container .main-search-input input { font-weight: 500; font-size: 17px; height: 57px !important; float: right; box-sizing: border-box; border: none; float: right; height: auto; } .search-container .main-search-input button.button { width: initial; min-width: 100px; max-width: 100px; margin: 0; font-size: 18px; position: relative; margin-right: 20px; flex: 0 auto; height: 57px; } .search-container .main-search-input button.button i { position: relative; right: 2px; } JS : (function($){ "use strict"; $(document).ready(function(){ function searchTypeButtons() { // Radio attr reset $('.search-type label.active input[type="radio"]').prop('checked',true); // Positioning indicator arrow var buttonWidth = $('.search-type label.active').width(); var arrowDist = $('.search-type label.active').position().left; $('.search-type-arrow').css('right', arrowDist + (buttonWidth/2) ); $('.search-type label').on('change', function() { $('.search-type input[type="radio"]').parent('label').removeClass('active'); $('.search-type input[type="radio"]:checked').parent('label').addClass('active'); // Positioning indicator arrow var buttonWidth = $('.search-type label.active').width(); var arrowDist = $('.search-type label.active').position().left; $('.search-type-arrow').css({ 'right': arrowDist + (buttonWidth/2), 'transition':'right 0.4s cubic-bezier(.87,-.41,.19,1.44)' }); }); } // Init if ($(".main-search-form").length){ searchTypeButtons(); $(window).on('load resize', function() { searchTypeButtons(); }); } // ------------------ End Document ------------------ // }); })(this.jQuery); I'm using bootstrap, bootstrap rtl flipped & jquery 2.2.0 as external ressources. Here's the snippet: https://jsfiddle.net/s3hy37nd/5/ Can someone help with that?
So many errors... I can only say I tried to comment them all inside the code so... yeah it's all there: "use strict"; jQuery(function($) { // DOM ready and $ alias secured // Radio attr reset (on DOM ready... makes sense?) $('.search-type label.active input[type="radio"]').prop('checked', true); function repositionArrow() { // Use a meaningful fn name // Positioning indicator arrow // Width? No. You need .outerWidth! you have paddings!! var buttonWidth = $('.search-type label.active').outerWidth(); // Again use meaningful names // If you do console.log( $('.search-type label.active').position() ); // you'll see no `.right` property. So yeah, use .left var posLeft = $('.search-type label.active').position().left; $('.search-type-arrow').css({ left: posLeft + (buttonWidth / 2) // No need for transition here - move it to Stylesheet instead }); } // Init if ($(".main-search-form").length) { // You might want this too inside the "if" $('.search-type label').on('change', function() { $('.search-type input[type="radio"]').parent('label').removeClass('active'); $('.search-type input[type="radio"]:checked').parent('label').addClass('active'); repositionArrow(); // Now you have such function }); repositionArrow(); $(window).on('load resize', repositionArrow); } }); body { direction: rtl; color: #707070; background-color: #cccccc; } .parallax { background-repeat: no-repeat; background-position: 50% 50%; position: relative; z-index: 99; } .parallax-overlay { position: absolute; top: 0; right: 0; width: 100%; height: 100%; z-index: 101; background-color: #333; opacity: 0.4; } .parallax-content { position: relative; z-index: 999; padding: 105px 0; } .main-search-container { transform: translate3d(0, -12px, 0); } .main-search-form { width: 660px; display: block; margin: 0 auto; position: relative; margin-top: 35px; } .search-type { display: inline-block; padding-bottom: 35px; position: relative; } .search-type input[type="radio"] { display: none; } .search-type label { position: relative; /* YOU NEED SOME POSITION! */ background-color: #fff; color: #333; cursor: pointer; display: inline-block; text-align: center; padding: 9px 18px; margin: 0 0 0 15px; /*float: right; WHY? you use rtl already */ transition: all 0.2s; border-radius: 3px; } .search-type label:hover, .search-type label.active { background-color: #66676b; color: #fff; } .search-type-arrow { width: 0; height: 0; border-right: 15px solid transparent; border-left: 15px solid transparent; border-bottom: 15px solid #fff; position: absolute; bottom: 0; /*right: 0; ...Nope. See JS, we need left */ left: calc(100% - 30px); /* calc to the rescue */ /*transform: translate3d(-3px,0,0); but why */ transition: left 0.4s cubic-bezier(.87, -.41, .19, 1.44); /* Moved from JS */ } .main-search-box { background-color: #fff; box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.12); padding: 30px; padding-bottom: 20px; margin-top: -9px; border-radius: 3px; } <div class="parallax-content"> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="main-search-container"> <form class="main-search-form"> <div class="search-type"> <label class="active"><input class="first-tab" name="tab" checked="checked" type="radio">TAB 1</label> <label><input name="tab" type="radio">TAB 2</label> <label><input name="tab" type="radio">TAB 3</label> <div class="search-type-arrow"></div> </div> <div class="main-search-box"> <div class="main-search-input larger-input"> </div> </div> </form> </div> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> Updated jsFiddle
Make navigation bar's dropdown stay
I've looked around SO and Google, but I haven't found an answer for my question (though I do feel this might be a very commonly asked one, still no luck anyway). All those I found were on jQuery, but I don't want to start jQuery without grasping adequate knowledge of the main JS. Basically, I have a simple website, and I'm now trying to make the frame of the navigation bar. The navigation bar will dropdown to display other options. My only question is how to make the dropdown STAY when I move out of the main element, that triggers the dropdown, and into the dropdown information. I noticed it's easier and neater to use CSS's :hover instead of JS, but I prefer to use JS as I'm still starting to learn a little bit of JS, so it's just to gain more knowledge. Please ignore all the colors and weird formatting in my code, it's just a frame for now that lets me see things better. PS: SORRY I HAVEN'T OPTIMISED THE TEXT AND VISUALS FOR RESIZED VIEWING AND IFRAMES. SORRY! Thanks in advance! :) document.getElementById("server").onmouseover = function() {serverMouseOver()}; document.getElementById("server").onmouseout = function() {serverMouseOut()}; function serverMouseOver() { document.getElementById("serverdropdownbox").style.display = "block"; } function serverMouseOut() { document.getElementById("serverdropdownbox").style.display = "none"; } .clearfix { clear: both; } body { background-color: rgb(21,14,43); background-image: url("../images/backgroundimage.jpg"); background-size: cover; background-repeat: no-repeat; background-attachment: fixed; min-height: 100%; background-position: center center; overflow: hidden; } #gigalogomainbox { float: left; width: 30vw; height: 10vw; overflow: hidden; transform: skewX(20deg); margin: 0 0 0 -4vw; background-color: white; } #gigalogobox { margin: 0 3vw 0 2vw; padding: 0 0 0 2vw; width: 100%; height: 8vw; } #gigalogo { width: 80%; margin: 3vw 2vw 0 0; height: 7vw; } #steamlogomainbox { width: 15vw; height: 10vw; float: right; margin: 0 -4vw 0 0; background-color: white; /*000c21*/ transform: skewX(-20deg); overflow: hidden; } #steamlogobox { margin: 0 -2vw 0 3vw; padding: 0; width: 100%; height: 20%; } #steamlogo { padding: 0 0 0 2vw; margin: 3vw 0vw 0 0; transform: skewX(20deg); height: 7vw; } #placeholderbartop { float: left; width: 60%; margin: 0; padding: 0; height: 10vw; } #navbarbox { clear: both; display: block; width: 100%; height: 5vw; padding: 2vw 0 0 0; margin: auto; } #navbar, #navbar ul { width: 100vw; height: 5vw; background-color: green; margin: auto; } #navbar li { color: white; list-style: none; display: inline-block; padding: 1vw 3vw 0 3vw; color: red; font-size:35px; } #serverdropdownbox { display: none; color: white; background-color: darkblue; } #serverdropdowncontent { list-style-type: none; width: 15vw; margin: 0 0 0 15vw; transform: skewX(15deg); } #serverdropdowncontent li { border: 1px solid white; font-size: 25px; text-align: center; padding: 1vw 0 1vw 0; } .menugradient { backround: darkblue; } #server { background-color: blue; } #server:hover #serverdropdownbox { display: block; } #gigalogomainbox:hover { background-color: red } <!DOCTYPE html> <html> <head> <link href="css/mainframe.css" type="text/css" rel=stylesheet> <script src="scripts/jquery.js"></script> </head> <body> <!--Giga logo, top left--> <div id="gigalogomainbox" class="clearfix"> <div id="gigalogobox"> <img id="gigalogo" src="images/gigalogo.png"> </div> </div> <!--Steam logo, top right--> <div id="steamlogomainbox"> <div id="steamlogobox"> <img id="steamlogo" src="images/steamlogo.png"> </div> </div> <!--navigation barrrrrr--> <div id="navbarbox"> <ul id="navbar"> <li>Home</li> <li id="server">Servers</li> <li>Community</li> <li>Store</li> <li>Download</li> <li>Contact</li> </ul> <div id="serverdropdownbox"> <ul id="serverdropdowncontent"> <li>Server List</li> <li>GigaDB</li> <li>CS:GO</li> </ul> </div> </div> <script src="scripts/frame.js"></script> </body> </html>
So, to fix this, it would be easy to fix this in jQuery. But the way to fix it in pure JS is to create multiple ids for the "Servers" content (li's,a tags). Then do the same thing you did with the "Servers" li in JS but with those id's that you created for the "Servers" content. Also, you should do that on id serverdropdowncontent. Best of Luck, Ben A.K.A BlackSky
Toggle Class while removing class from siblings
I have a map where I am toggling a class when you click on a dot/location that pops up a tooltip. The issue I'm running into is that when I click on another dot the other siblings tooltips are not going away. I tried to solve this by removing the class of the siblings on click, but when I do this the toggle stops working and I cannot click the dot again to get rid of the active tooltip. I need the toggle on the currently active tooltip to still work but I also need the sibling tooltips to disappear as well. I hope I explained that right. Here is a codepen: http://codepen.io/anon/pen/BzQrLV $('.dot').click(function() { $('div.toggle-active').removeClass('toggle-active'); $(this).next().toggleClass('toggle-active'); }); #map { position: relative; width: 100%; max-width: 580px; } #map img { max-width: 100%; } /** DOTS **/ .dot { background-color: #fff; border: 1px solid #fff; border-radius: 50%; cursor: pointer; display: inline-block; height: 10px; position: absolute; width: 10px; } .dot:hover { background-color: #00A24B; } .dot-oregon-greshman { top: 15%; left: 11%; } .dot-oregon-oregon-city { top: 16.5%; left: 11%; } /** TOOLTIPS **/ .tooltip::before { content: ""; height: 0; width: 0; border-style: solid; border-width: 12.5px 21.7px 12.5px 0; border-color: transparent #01872B transparent transparent; position: absolute; top: 50%; left: -6%; transform: translateY(-50%); } .tooltip { opacity: 0; background-color: #01872B; color: #fff; padding: 10px 10px 10px 20px; font-size: 12px; width: 186px; position: absolute; line-height: 14px; transition: all 300ms ease-in-out; } .tooltip.toggle-active { opacity: 1; } .tooltip p { margin: 3px 0; } .tooltip a { color: #fff; } .tooltip a:hover { color: #c3ecff; text-decoration: none; } .tooltip strong { color: #fff; font-size: 14px; } .tooltip-oregon-greshman { top: 10%; left: 16%; } .tooltip-oregon-oregon-city { top: 11.5%; left: 17%; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="map-section"> <div class="map-container"> <div id="map"> <img src="http://openpathinvestments.com/wp-content/themes/boilerplate/images/map-blue.png" alt=""> <div class="locations"> <div class="dot dot-oregon-greshman"></div> <div class="tooltip tooltip-oregon-greshman"> <strong>Stark Street Crossings</strong> <p>Greshman, Oregon 97030</p> <p>Property Profile | Website </p> </div> <div class="dot dot-oregon-oregon-city"></div> <div class="tooltip tooltip-oregon-oregon-city"> <strong>The Preserve</strong> <p>Oregon City, Oregon 97045</p> <p>Property Profile | Website </p> </div> </div> </div> </div> </div>
Add .not($(this).next()) to your removeClass statement so you don't remove the active class from all the dots, just the dots not being clicked on. $('.dot').click(function() { $('div.toggle-active').not($(this).next()).removeClass('toggle-active'); $(this).next().toggleClass('toggle-active'); }); #map { position: relative; width: 100%; max-width: 580px; } #map img { max-width: 100%; } /** DOTS **/ .dot { background-color: #fff; border: 1px solid #fff; border-radius: 50%; cursor: pointer; display: inline-block; height: 10px; position: absolute; width: 10px; } .dot:hover { background-color: #00A24B; } .dot-oregon-greshman { top: 15%; left: 11%; } .dot-oregon-oregon-city { top: 16.5%; left: 11%; } /** TOOLTIPS **/ .tooltip::before { content: ""; height: 0; width: 0; border-style: solid; border-width: 12.5px 21.7px 12.5px 0; border-color: transparent #01872B transparent transparent; position: absolute; top: 50%; left: -6%; transform: translateY(-50%); } .tooltip { opacity: 0; background-color: #01872B; color: #fff; padding: 10px 10px 10px 20px; font-size: 12px; width: 186px; position: absolute; line-height: 14px; transition: all 300ms ease-in-out; } .tooltip.toggle-active { opacity: 1; } .tooltip p { margin: 3px 0; } .tooltip a { color: #fff; } .tooltip a:hover { color: #c3ecff; text-decoration: none; } .tooltip strong { color: #fff; font-size: 14px; } .tooltip-oregon-greshman { top: 10%; left: 16%; } .tooltip-oregon-oregon-city { top: 11.5%; left: 17%; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> HTML <div class="map-section"> <div class="map-container"> <div id="map"> <img src="http://openpathinvestments.com/wp-content/themes/boilerplate/images/map-blue.png" alt=""> <div class="locations"> <div class="dot dot-oregon-greshman"></div> <div class="tooltip tooltip-oregon-greshman"> <strong>Stark Street Crossings</strong> <p>Greshman, Oregon 97030</p> <p>Property Profile | Website </p> </div> <div class="dot dot-oregon-oregon-city"></div> <div class="tooltip tooltip-oregon-oregon-city"> <strong>The Preserve</strong> <p>Oregon City, Oregon 97045</p> <p>Property Profile | Website </p> </div> </div> </div> </div> </div>
Updated to check whether the tooltip was already being displayed before displaying it. $('.dot').click(function() { var displayed = $(this).next().attr('class').match('toggle-active'); $('div.toggle-active').removeClass('toggle-active'); if(!displayed){ $(this).next().toggleClass('toggle-active'); } });