Creating a slider [closed] - javascript

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 4 days ago.
Improve this question
I'm Having difficulties creating a slider with 3 different images.
I have a problem selecting the previous image when clicking on previous button in the slider.
Here is my javascript code
let images=['dice-1.png','dice-2.png','dice-3.png'];
var i =0;
function slideShow() {
document.getElementById("image").src=images[i];
if(i<images.length-1){
i++;
}
else {
i=0;
}
}
function prevSlide(){
document.getElementById("image").src=images[i];
if(i>images.length-1){
i--;
}
}
document.querySelector('.nxt').addEventListener('click', slideShow);
document.querySelector('.pr').addEventListener('click', prevSlide);

Related

Javascript Dom Products Listing [closed]

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 1 year ago.
Improve this question
there is a simple order page on my website that I have prepared to improve myself.
When the order page is opened ,the" 1 piece " option is selected.
Do this " document.getElementById ('mark1').click () " I did it thanks to this code. But when you click on 1pc, you will see that it comes in their products.
My request is that 1 option is selected when the site is opened and the products are listed. How can I do this?
Page: https://fcproje.com/nike/siparis.php
Clicking that <input type='radio'> seems to trigger the following code on line 598 of your file
$("#mark1").on('click', function() {
var markalar = this.dataset.id;
var mainid=1;
if(markalar){
for (var i =1; i <= mainid; i++) {
sender(i,markalar);
}
}
});
You could simulate this code after the code you use to click on the radio button.
So change this line
document.getElementById('mark1').click()
To this block of code;
document.getElementById('mark1').click();
(function(){
var markalar = "1"; // The Dataset.id of the input was "1" so add it here
var mainid=1;
if(markalar){
for (var i =1; i <= mainid; i++) {
sender(i,markalar);
}
}
})();
The code is wrapped in an anonymous function as to not add unnecessary variables to the global window object.

Can I get sound from only right/left earphone with javascript? [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 2 years ago.
Improve this question
When I play a sound with js, I just want the sound coming from the right. how can I do that
Yes. Check out StereoPannerNode from the Web Audio API.
The pan property takes a unitless value between -1 (full left pan) and
1 (full right pan). This interface was introduced as a much simpler
way to apply a simple panning effect than having to use a full
PannerNode.
Also see this example: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API#Adding_stereo_panning_to_our_app:
const pannerOptions = { pan: 0 };
const panner = new StereoPannerNode(audioContext, pannerOptions);
<input type="range" id="panner" min="-1" max="1" value="0" step="0.01">
const pannerControl = document.querySelector('#panner');
pannerControl.addEventListener('input', function() {
panner.pan.value = this.value;
}, false);
track.connect(gainNode).connect(panner).connect(audioContext.destination);
(Note: this isn't specific to Vue)

how To Use Change event of BootstrapSlider in JQuery [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 3 years ago.
Improve this question
i Have Two Question About Bootstarp Slider
First How can I use change event in BootstrapSlider and get value
and Second is how to change initial value of bootstrap slider
You can use .on('chnage', callback_function) to listen to value changes
and set the data-slider-value=< any number > to initialize the starting value
<input
type="text"
name="somename"
data-slider-value="20"
data-provide="slider"
data-slider-min="1"
data-slider-max="100"
data-slider-step="1"
data-slider-tooltip="hide"
>
// Instantiate a slider
var mySlider = $("input").slider();
//This will get called for every chnage
mySlider.on('change',function(){
//getting value from slider
var value = mySlider.slider('getValue');
console.log(value)
})

Change CSS when the current URL contains a certain string [closed]

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 6 years ago.
Improve this question
I used this function for checking the url
<script type="text/javascript">
$(document).ready(function () {
if (window.location.href.indexOf("franky") > -1) {
/* some code to change the css */;
}
});
</script>
Currently it only works when I refresh the page.
Is there a way to make it work when url change without any refresh ? Thanks
EXAMPLE : its like you have to choose a color , you click on a button to select your color , it make example.com/color.html#/red ; example.com/color.html#/blue ; example.com/color.html#/black only the color change with no refresh and i want to add specific css when url contain each string color
black
blue
<script type="text/javascript">
$(window).on('hashchange', function(e){
var origEvent = e.originalEvent;
resultdata = origEvent.newURL;
var black = resultdata.match(/black/);
if (black){
console.log(black);
}
});
</script>

Put two submit button at same place [closed]

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 6 years ago.
Improve this question
is there any way to put two submit button at same position?Since I have submit button with hidden attribute based on dropdown,it will show up desirable button upon selection.
Are you trying to achieve something like this?
The main thing you need to look at, is that each button is positioned absolutely and has the same left and right.
var button1El = document.getElementById("button1");
var button2El = document.getElementById("button2");
button1El.addEventListener("click",function() {
this.style.display="none";
button2El.style.display = "block";
})
button2El.addEventListener("click",function() {
this.style.display="none";
button1El.style.display = "block";
})
button{
position:absolute;
left:10px;
top:10px;
}
#button2{
display:none;
}
<button id="button1">Button 1</button>
<button id="button2">Button 2</button>

Categories

Resources