Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I need to create a link or a button so that users can navigate to different urls (needs to be generated in a js function based on values selected in multiple dropdown)
I tried with a button but it doesn't navigate to the link, and with not able to change values of href it adds to previous values.
Can you please help
function link(url){
window.location.assign(url);
}
<button onclick="link('http://www.stackoverflow.com/')">Go to Stack Overflow without using an <a>!</button>
Try this:
https://jsfiddle.net/ykc8mLwj/
$(function() {
$("#id-of-your-select").on("change", function() {
$("#id-of-your-link").attr("href", $(this).val());
});
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm trying to not display element after it was clicked, but the onclick method gets called when the page loads and then it does not get called when I click it. This is my code.
$(document).ready(function() {
$(".close").on('click', function(){
$(this).parent().parent().css("display","none");
});
}
What's the problem here?
The question is unclear. But your element is either not available on the dom from the beginning or you have not selected properly the element you want to hide.
Try this:
$(document).ready(function() {
$("body").on('click', '.close',function(){
$(this).closest("insert-element-name").css("display","none");
});
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Simple enough question, but I've spent a few hours and can't figure it out.
Some background:
Using dropzone.js I have set an entire page to be a dropzone.
I properly handle the file upload.
Issue:
I want to trigger a JavaScript function to do something (lets say trigger an alert) whenever a person drops any file anywhere on the screen. How would I best achieve this?
Dropzone.js has a drop event which can be triggered like below:
$(function() {
var myDropzone = new Dropzone("#my-dropzone");
myDropzone.on("drop", function(file) {
//code here
});
})
see http://www.dropzonejs.com/#events for all events.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Not sure what is causing this problem, if you click Request A Quote from this page you'll notice that even if you fill out the form, it doesn't submit! I'm pretty sure this may be down to a JS conflict but thought I'd post it up here in case I'm way off....
Any help would be much appreciated.
Cheers!
You are using a regular link a to submit the form, do you manage the click event with JS in any way?
Since you're using the HTML form, why not simply use a button :
<button class="button-submit">Request a quote</button>
Or, add this to your link : onclick="form.submit();".
Like so :
Request a quote
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm creating text fields each time a button is clicked, with each new div I create I also want to give it a button to delete this field. As can be seen in this JSFiddle.
However the button associated with each newly created div doesn't delete it's associated field. How can this delete that text fields?
You have to use delegation.
This works for the elements new to the DOM, after it was already loaded.
$(document).on('click','.deleteButton',function(){
$(this).closest('.form-group').hide();//remove
});
JSFiddle
Note: I added deleteButton class to the dynamically inserted buttons.
You can set in your button an onclick function and handle delete there like following:
window.deleteRow = function(obj){
$(obj).parent().remove();
}
fiddle
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I need to get the current active element on my web page I used
$(document.activeElement)[0].id
This is working fine in Internet Explorer, but in Firefox it always return empty string ""
Please tell me how can I get active element's id in Firefox?
Here is a simple scenario
I have 2 div with ID div1 and div2 respectively, now when user click on them I should get it's ID
Here is my markup
http://pastebin.com/BCW8ECMx
Why not use the event's target:
$(document).ready(function () {
$(document).click(function (e) {
alert(e.target.id);
});
});
JSFiddle example found here.
The problem is not in the code. But, the fact that, div cannot be active.
In fact, elements, which a user cannot interact, cannot be active.
For such elements, the id of the <body> will be returned.