dom-manipulation

Building a web crawler - using Webkit packages

I'm trying to build a web crawler. I need 2 things: Convert the HTML into a DOM object. Execute existing Javascripts on demand. The result I expect is a DOM Object, where the Javascript that executes on-load is already executed. Also, I need an option to execute on demand additional Javascripts (on events like: onMouseOver, onMouseClick...

Trouble programatically adding CSS to IE

Hi all, I have a bookmarklet which inserts a CSS stylesheet into the target DOM via a "link" tag (external stylesheet). Recently, this stopped working on Amazon.com, in Internet Explorer only. It works on other sites, and with other browsers (even on Amazon.com). The technique we're using to insert the stylesheet is pretty straightfo...

Can you safely manipulate the DOM with Sharepoint (MOSS 2007)and jQuery?

We have a MOSS 2007 installation where we rely on jQuery to handle automatic rotation of tabs in webparts, animation of sliding menus and tool panels. Intermittently we get the "Operation Aborted" error with our IE 6 users. While we confirmed that this results from manipulating the DOM before it has been completely loaded on the clie...

How do I wrap a page element with a dynamically generated element using jQuery?

I have the following code var input = $('#el_id'); wrapper = $(document.createElement('div')); wrapper.addClass('small'); wrapper.css('width',200); input.wrap(wrapper); alert(input.children().length) I get 0 for the children length. What I want is: <div class="small" style="width: 200px;"> <input type="text" id="el_id" /> </di...

How can I make this javascript more efficient?

Hi, i am receiving a piece of plain html from an ajax request. <h1>Title</h1> <div> content </div> This is the most simple form. Every piece contains a <h1> tag for a title, and a <div> tag containing the content. I have a nicely formatted container in the html page which needs to populate with the returned html snippet. This is t...

Creating tables dynamically in jQuery

Hey everyone, I'm building some data dynamically using jQuery, but I'm getting the following error: Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3 This happens at the appendTo part of a script that looks like this: $('<tr />').append( /* lots of stuff */ ).add( $('<tr />') ).append( /* some more */ ).appendTo($tbody...

Does jQuery automatically remove attached even handlers from objects when I remove them?

Well my interest is whether jQuery does remove attached event handlers from the DOM object and all it's descendants (if they got some event handlers attached as well), if I just remove that DOM object with jQuery('.selector').remove()? ...

clear all divs' contents inside a div

I have a div <div id="masterdiv"> in which i will have several child divs. For example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="childdiv3" /> </div> I need to clear the contents of all child divs inside the master div using jquery. How to achieve it? ...

clone() in jquery problem with IE and chrome

i am trying to clone a particular div and do some manipulation to clear the content and return. var tmp = $('<div>').append($('#masterdiv').clone()).remove().html(); It works fine in firefox. but in IE and chrome, this removed the entire div instead of cloning. Whats the workaround for this? Edit: The main aim is to copy the entire...

problem with jquery's clone in IE and Chrome

I am trying to copy the masterdiv contents including child divs. Below is the code implementation. <label id="lblMessage" /> <table width="100%"> <tr> <td> <div id="colorSelector"> <div style="background-color: rgb(0, 0, 255);" /> </div> </td> </tr> <tr> <td> ...

check not contains in div html

I have a div <div id="maindiv"></div> and some checkboxes to add some html element inside that maindiv. When i check that checkbox, i need to append <div id="subdiv"></div> after checking that it doesn't contains that element. The subdiv id will vary according to the checkbox selected. When i uncheck the checkbox, i need to remove the ...

Dynamic content in 2 columns (rather than one!)

Hello, I have one table which display data as from Dynamic Content in 1 column. I would like the content to move to a second column when the number of cell is >3. (ie. if there are 3 cells to display, it would be display in 1 col, and 4 cells or more it would be displayed in 2 columns. Note that the dynamic content will never go over 6 ...

jQuery add class to certain elements

[EDIT] : Sorry guys, the whole post didn't go through. Here is the correct post. Hi, I have a multilevel menu like this : <ul> <li>item 1 <ul> <li>item 1.1</li> <li>item 1.2</li> </ul> </li> <li>item 2</li> <li>item 3 <ul> <li>item 3.1</li> <li>item 3.2</li> </ul> </li> <li>item 4</...

Moving around jquery ajax loaded content to be reusable

I have several links that points to a single AJAX url. I can load it into a single #DIV, for each request with patterns: load and remove for each link. Now since all I need is a single url, I am trying to avoid removal and re-request procedure. I have two scenarios, still questioning and badly need suggestions to also handle them: Cre...

templates vs DOM creation - highly dynamic interface

Hi, Building a browsergame I came from PHP to JavaScript, which I now also want to use at the server side. As I'm going to require Users to have JavaScript either way, I'm going to take extensive use of it. I want to use in in a object-oriented way though. Considering MVC, Models will be used on both client and server side. Views are on...

Manipulating classes with jquery

Hi, jquery masters, I have a select box with values: apple-80 apple-100 apple-120 apple-300 I have: <body class="fruit apple-120 otherclass anotherclass"> I want to manipulate the body class "apple-120" to get replaced by any of selected value from the select box while keeping the fruit, otherclass, anotherclass, class untouched. So ...

Manipulating some selector classes based on select box values

I am trying to refine my custom jquery plugin. I have asked this before here. The previous problem was resolved. Now I want to make my plugin more flexible. So instead of relying on hardcoded old classes, I am trying to make it rely on the array of values of the select box which dynamically change the classes based on their values. The r...

Insert after parent of element

What sort of selector would be I need in order to insert after the parent (divouter) of the test3 class in the example below? Thanks. <div class='divouter'> <div class='divinner'> <input class=test1></input> </div> </div> <div class='divouter'> <div class='divinner'> <input class=test2></input> </div> </d...

Event to remove element before

How would I write an event in jQuery so that if I click any of the links it'll delete not the divouter surrounding it, but the divouter before it? <div class='divouter'> <a href='#'>Link</a> </div> <div class='divouter'> <a href='#'>Link</a> </div> <div class='divouter'> <a href='#'>Link</a> </div> <div class...

Remove element with jQuery but leave text

I've got some html that looks like this: <div> <span class="red">red text</span> some more text <span class="blue">blue text</span> </div> What I want to do is use jQuery to remove all the spans within the div regardless of attached class, but leave the text within the span tags behind. So the final result will be: <div> red ...