Delegated on click not working on div [closed] - javascript

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
$(document).on('click', 'div.item_2', function(){
alert('buy');
});
the item exists on the page, anyway this should work no matter if the element exist or not, its a delegated click, but I can't understand why it not work on my:
<div class="item_2">
</div>
there are no event removers, where I should look to find a bug? cause I don't see any reason that it should not work...

A div that is not visible will not fire the click. See this question.

Are you sure you've included jQuery in the <head>?
Are you running on your local filesystem? If you copy and paste from jQuery from google:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
It won't work on your local file system. You'll need to add http: to the url:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Related

jQuery change input button value attribute text after click [closed]

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.

JS Can not use click function after append [closed]

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/

is there away to get the path of HTML element [closed]

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 trying to change or remove errors from a HTML page I'm using firebug add in firefox and I have this part which I really don't where its writen :
is there a way to get the file where this is write .
thanks for any hint
Continuing from my comment: The highlighted element is dynamically added by a slider plugin e.g. like http://jqueryui.com/slider/ The clue is the classes like ui-slider-handler.
Look for the id="voltage" to find the place in the HTML where the div is and look for #voltage or ("voltage" or 'voltage') to see where the plugin is connect to it (in any jQuery or Javascript code).
I don't think you can get the exact path of the file, but check "View page source" option to see what files the page has been linked to.

Ajax page reloading + Foundation [closed]

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 have an issue with my website:
http://td.lbmedia.pl
After clicking on menu's link page smoothly reloads using ajax but... the foundation javascripts are going down. Can anyone suggest me what is the problem?
The issue is event handlers being destroyed after ajax page load, one way to solve the issue is (since I couldn't find the documentation for that plugin) using global ajax event handlers
$( document ).ajaxComplete(function() {
$(document).foundation();
});

jQuery and JavaScript onmouseover compatibility [closed]

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
});

Categories