JQuery :: Does Remove() Unbind Events On Children
Dec 8, 2010When calling remove on a selector, I understand that events & data are removed from the matched elements. What about children of these nodes, is the same true?
View 1 RepliesWhen calling remove on a selector, I understand that events & data are removed from the matched elements. What about children of these nodes, is the same true?
View 1 Replieswhen is bind some jquery events to, for example, <p id="test">. and later i remove this HTML with jquery should i unbind all events first or are they unbinded with removing the html?
View 3 Replies View Relatedhow can I unbind or remove a function with jquery?
for instance, this is my html,
Code:
<li><img src="..." alt="1"></li>
<li><img src="..." alt="2"></li>
<li><img src="..." alt="3"></li>
[Code]....
I'm having some difficulties with a menu I'm making. I build up the
menu through DOM. I append childnodes to a tree. 2 types of children
are possible: url (a hyperlink) and sub (a submap).
The tree is thus of a structure
main
|-url1
|-url2
|-submap
|--url21
|--url22
To open up the submaps I set the onclick event to a function I
created:
itemnode.onclick=function() { openMap(itemnode) }
The problem now is that 1 click in a submap results in several times
the openmap function. A click on the url21 node is in fact a click on
a child of submap so the function in the onclick event of this submap
is called. But it is also a click on a child of main, so this onclick
function is also called.
How can you limit that the onclick event handler is only called on the
1 node (ic. submap) where you actually clicked on submap instead of
its urls?
Full code listing below....
Is it possible to remove a DOM node in Javascript without removing its children nodes. say I have
<div id="ParentDiv">
<div id="child1"></div>
<div id="child1"></div>
</div>
Can i remove ParentDiv but still keep Child1,Child2 on the DOM tree?
I am finding that remove() does not remove live events. I'm wondering why this is. I've also noticed that the selector for .die() has to be specificand I can not simply do $("*").die().Is there a reason for this? I found that if I use delegate instead of live then it does get detached. I'd like to understand this since it's causing double/triple event triggering in my pages.
View 2 Replies View RelatedIm working on a Grid system, which has the following features: On tr hover I have added a click event, which triggers an edit mode When switching to edit mode, the click event is unbind, so that one cannot edit multiple rows simultaniously After update, I'd like to re-bind the previous click functionality. However, I cant seem to do that. My code either does nothing, or Im getting an Jquery error below. Trying to define the original click event again does not work either. So what am I missing here? How can I re-bind an un-bind event ? Or can I?
[Code]...
I have the following piece of jQuery:
$("img[alt='47767']").unbind('click').attr('src', '../images/icon-tick.png').attr('title', 'Printed');
Which I am trying to use to manipulate the following piece of HTML<img alt="47767" title="Mark as printed" style="cursor: pointer;" onclick="mark_printed(this)" src="../images/icon-printer.png">The attribute changes for 'src' and 'title' get applied, but the unbind('click') doesn't stop the image from firing the 'mark_printed(this)' function.Why is unbind('click') not working as expected?
I have a slight problem in FF3.5 that unbind('keydown'); is not working properly..
$("#q").unbind('keydown');
$("#q").keydown(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
if(code==40 || code==38) {
var totalResults=$("#quick-search-results li");
var selectedResults=$("#quick-search-results li.qs-selected");
if(code==40) {
var nodeIndex=($("#quick-search-results li.qs-selected").length<=0) ? 0 : $("#quick-search-results").index('li.qs-selected');
alert(nodeIndex);
}}}); // end keydown
The above code alerts once on first keydown (with the down arrow key [code==40]), twice on the second, three times on the third and so on.. it worked fine in FF3 but a recent upgrade to FF3.5 seems to have broken the functionality..
I'm trying to create a scroll bar through javascript with the help of jquery. What I'm trying to accomplish is:1. When the user mouse's down, it fires off an event (mouse move) and allow the user to scroll.2. When the user mouse's up, it should unbind the event, so that the mouse move is not in effect any more.But unbind is not working as expected. I looked up the documentation, and it seems correct.
Code JavaScript:
$(document).ready(function() {
$('#scrollBar').mousedown(function(e) {
[code]....
I am trying to "ajaxify" my site. Now I have one problem:
$("#posts").children().remove();
$("#tag-sidebar").children().remove();
$.each(data.Tags_Sidebar, function (indexInArray, valueOfElement) {
var insert = $("<li>");
[Code]......
Now when I click one of those links (href1, href2, href3) generated, the click event won't execute! What's the problem? Also, is it right that I have to transfer the valueOfElement over, like I did? What does stopEventPropagation do? Prevent the href from being navigated to? That's what I am trying to do.
The data object is JSON fed from here:[URL]
The HTML is here: [URL]
I have a series of images with an animation bound to mouseover and mouseleave events, and I'm trying to get my head around adding a click event that would prevent the mouseleave animation from occurring only for the image that was clicked, preserving everything else as is (until another image is clicked). I've discovered .stop() and I think I'm getting close, but some part of the logic is still escaping me.
View 3 Replies View RelatedThis time I have a trouble with remove(). Here is my code :
$.each(val.produitsIds,
function (j, val2) {
if($('#chk_' + i).prop("checked")){
//$('#' + val2).prepend("<div>liste des tailles</div>");
$('#' + val2).prepend("<div>" + $('#chk_' + i).attr("value") + "</div>");
}
[Code]...
I want to remove a specific box when i click on the remove button in that box. I have a lot of boxes on a page but when i click on the remove btn it removes all the boxes. I just want to remove the box where i click on the delete btn.
This is the js code:
$(".del").click(function() {
$('div.floating-box').remove();
});
[Code].....
i want to get the ids of all the children of id 'top' and store it in an array in the order listed above. so final output in this case would be:
arr[0] = 1
arr[1] = 2
arr[2] = 3
is there a function or simple procedure that help me do this?
I have a div containing many children all very different, each one as a different width. I need to get the width of all the children. I mean child1.width() + child2.width() + child3.width() etc... Of course as a new child can be added anytime I can not use the kind of things I put above.
I tried that among other things :
$("div.mydiv").children().width();
But I only get the width ofthe first child.
I have about 13 ul li a items in a list and some have nested lists within them e.g. ul li ul li a and some don't. I want to prevent the default action on only a elements that have nested lists within them but not prevent default action for ones that don't. Here's an example of the markup.
[Code]...
However, instead, is there a way to tell jQuery to only apply this preventDefault to ul li a elements that have ul li a descendants/children (not sure of correct terminology here) so I can have the list items in any order?
just wondering if there is any way for the :contains to not look in children to find something? Tried $(':contains("$")');, but it returns everything. Was thinking of something like $(":not(':parent')").filter(':contains("$")');, but the console returns null (and even then it would exclude elements that have children and their text includes "$".)
Trying to make a script that looks through a page and finds the price on any page. The only way I could think of doing this relatively accurately is to search for all elements with "$" in the text, then get the one that has the largest height/width (That's problem #2, I think -- will deal with it once i get there :)
I'm trying to get an unordered list and its children as an HTML string on a mouseout event, but html()only selects the child elements:var theHtml = $('ul', this).html();I've tried using andSelf(), but that doesn't return the result I want:var theHtml =$('ul',this).and Self(). html();I can't choose $(this).html() as I need only the list.
View 2 Replies View RelatedI have:
<dt><a href="javascript:void(0);">Menu 1</a>
<dd>
<....>
[code]....
Given the following markup
<div id="menu">
<ul>
<li><a id="home" href="#">Home</a></li>
<li>
<a id="about" href="#">About</a>
<div>
About sub menu
</div></li><li>
<a id="products" href="#">Products</a>
<div><h2>Books</h2>
<ul><li>ColdFusion</li>
<li>jQuery</li>
<li>CSS</li>
<li>HTML</li>
<li>Groovy</li>
<li>Hibernate</li> .....
How can I grab only the 1st level children of my node? I want direct decendents of menu only. My code below is grabbing all <li> which is going to be a problem.
(function($){
$.fn.extend({
myplugin: function(options){
return this.each(function(){
// the object we are working with
var obj = $(this);
// get a list of menu items
var menuItems = $('li',obj);
});
}});
})(jQuery);
Taking the following markup
<div id="menu">
<ul>
<li><a id="home" href="#">Home</a></li>
<li>
<a id="about" href="#">About</a>
<div>
About sub menu
</div>
</li>
<li>
<a id="products" href="#">Products</a>
<div>
<h2>Books</h2> .....
How can I grab the immediate li children only and not all of the li that fall in this object. The following gives me every single <li> which is not what I am looking for.
(function($){
$.fn.extend({
myplugin: function(options){
return this.each(function(){
// the object we are working with
var obj = $(this);
// get a list of menu items
var menuItems = $('li',obj);
});
}});
})(jQuery);
I'm a beginner at using jQuery for website interaction and I needed to create a simple sidebar menu. Here is the HTML code:
Code HTML4Strict:
<ul id="sidenav">
<li><a href="#">2010</a>
<ul>
<li><a href="#">January</a></li>
<li><a href="#">February</a></li>
[Code]...
It basically works, but only if I remove the code part where I first hide the children of the sidenav, but doesn't work when I want at default all children of the sidenav to be hidden and showed only if clicked a particular parent menu. 1. How can this be accomplished? 2. Also how can I hide the children of previous clicked parents when I click on another parent to chow it's children?
I am trying to assign a variable to a jquery object that is found using the children() and eq() methods. This is a simplified version of the html structure.[code]Here is the jquery code. All I want to do is assign an object to the variable and be able to manipulate the object through the variable. [code]Again this is a simplified version of my code but the structure is similar.
View 2 Replies View RelatedI have the following html and I'm trying to figure out how to delete the last rows the are children of div feed. I only want to leave a max of the first x rows. First I count them using $numdivs = $("#feed > div").size() - 1;. Then, I'm a bit lost on what to do next and have looked at the docs for children and thought of trying to traverse but can't seem to get it to work.
<body>
<div id="search">
</div>
<div id="feed">
<h2>Feed</h2>
<div id="firstrow" class="row"/>
<div id="1741946459" class="row">Test data for the first row</div>
<div id="1741946327" class="row">Test data for the second row</div>
<div id="1741939928" class="row">Test data for the blah row</div>
<div id="1741939928" class="row">Test data for the blah2 row</div>
<div id="1741939928" class="row">Test data for the blah3 row</div>
</div>
</body>
How to find grand children in a page
View 2 Replies View Related