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
So, i am in the midst of making a little website where you can calculate right angled triangles. Y'know, just for the fun of it.
Atm, i'm testing the real time calculation of the different html forms, however, i can't figure out why the form for cathetusB isn't updating.
Any help is appreciated!
This is how all the forms are set up: <input type="number" step="0.01" id="someID" onkeyup=calculate();>
The JS code messed up when i tried to paste it in, so here's a fiddle!
EDIT: Added all the code to the Fiddle!
You have configured JSFiddle so that the code runs in an onload event handler.
The functions are therefore scoped to that handler function.
They are not globals.
They are not accessible to your intrinsic event handlers.
Configure JSFiddle to place the JS in the body instead of onload and the code works.
It would be better to replace your intrinsic event handler attributes with programatic event binding.
Be careful when using this :
<input type="number" step="0.01" id="cathetusA" onkeyup=calculate();>
If you are using the same id with every form things your code will not work.
Id must be unique for every object
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 7 years ago.
Improve this question
I'm testing some javascript on jsfiddle and for some reason I can't get a function to fire on a button click. Any advice?
jsfiddle link
In the Frameworks & Extensions panel, set onLoad to No wrap - in <body>.
It took me a while to figure this out.
You have configured JSFiddle to wrap the code in an onload event handler. Consequently the function you are trying to call onclick is out of scope.
Don't use intrinsic event attributes. Use jQuery's (since you are using jQuery already) event binding instead.
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
I got a problem with my jQuery code on a Website.
Website: LastDeath
I want what the title says, to change the value text in an input button(Send Button).
I've already Googled and tested some code snippets from other questions, but it doesn't fix my problem. So I asking U guys! :)
If u open the console(in chrome #chromelover) go to sources, js, jq-main.js
you can see the current code snippet(MESSAGE FORM) for the input button, test.. do whatever you want with it and I would appreciate a comment.
Thanks,
Mike.
A few things:
Load jquery first using:
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
I would start with:
$(document).ready() ...
As I've never seen $().ready().
I guess it's what's breaking your code.
I don't understand your idea of changing the text on the button as it is the submit button and the page would be reloaded. In case you want to submit using an AJAX request later, you may want to use preventDefault (https://api.jquery.com/event.preventdefault/) to prevent page reload.
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
I add my TRIGGER DIV A over $(".DIVB").html(data); from a AJAx Responsebut when i now want to trigger some code over the $(".TRIGGER DIV A").click(function() it isnt working. Can someone explain me why ? And is there a Way to fix this or is there a working arround ?
It looks like you're using jQuery's .click(). If HTML is added dynamically to the DOM, you need to bind the click event to the element after it has been added. Otherwise, when $(".TRIGGER DIV A").click(handler) runs and jQuery looks for the element to bind, it isn't able to find it.
You may consider using .delegate() instead. This ensures that the event is bound to all elements relevant to the given selector regardless of when it is added to the DOM. You can find the documentation for usage here: http://api.jquery.com/delegate/
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 3 years ago.
Improve this question
I've created an eBay listing and it work's correctly on eBay.
But I have an issue. The listing's are listed via 3rd party software and that software has their own JS for changing the images. And it doesn't work with my scripts. I use jQuery.
Can anyone advice a simple method to swap the image src on click event?
For example: Leave as it is, but overwrite the JS. Now it is set up to listen for mouse hover. Can I write a new script so when clicked it would swap the images?
Here is the link to the listing: Listing template here
To change src attribute of an image :
$('#myImage').click(function(){
$(this).attr('src', 'myNewImage.jpg');
});
To stop listening to the mouseover event :
$('#myTargetWhichHasAnEventAttached').off('mouseover');
Edit to answer the comment :
$('.image_small_js').off('mouseover'); // supposed that the mouseover event is attached on .image_small_js
$('.image_small_js').click(function(){
$('#bigpicture').attr('src', $(this).attr('src')).hide().show(); // .hide().show() makes the change effect more smoothy... can be used with timers
});
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 have my own page where I load an external third-party JavaScript that analyzes my DOM. The problem I am facing is as follows. I install some event listeners ('keypress', 'input', 'click') but after I append mentioned script (and she performs some computation), some of my listeners are not working any more. To be precise, 'click' listener is intercepting click events as expected, but other two are not intercepting anything. Is there a way for that external script to interfere with my listeners?
Btw., I am setting useCapture to true when installing my listeners, like this:
document.addEventListener('input', function...., true);
...
I don't have any other code to provide you with.
P.S. I am not able to play with the external code since it is obfuscated.
P.P.S. Installing the handlers again did not help.
It is possible, although quite unlikely, that the third-party code is capturing the event(s) before and and stopping it propagating (e.stopPropagation()). This would require the code attaching a listener to the same event on a parent element in the capturing phase.
Without more code to see, particularly this third-party code, it's hard to find the actual problem.