I have markup like this:
<p>one two three four</p>
And I want to use javascript to convert it to this:
<p>one <span>two three<span> four</p>
I have the offset and length of the section I want to wrap in a span, in this case offset = 4 and length = 9. If using jQuery can make it easier, that is preferable.
...
I have an html like this:
<div id="container1">
<div class="dragme">drag me</div>
</div>
<div id="container2">
<div class="dragme">drag me</div>
</div>
<div id="droponme"></div>
$(".dragme").draggable();
$("#droponme").droppable({
accept: ".dragme",
drop: function(e, u) { alert( /* find id of the container here*/ ); };
...
The DOM NodeList (as returned e.g. by element.getElementsByTagName) is an interesting object, in that it is not a snapshot, but reflects changes to the document made after you have created the NodeList.
I was wondering how one would implement such a collection: Completely lazy evaluation must be horribly slow, but keeping a cached vers...
I have a Yahoo! Widgets Web object ( http://tinyurl.com/YW-webObj ) and I'd like to access elements inside of it when it's done loading. I'm already handling everything wonderfully via the WebEvents Y!W provides, but there's one small problem.
Web objects don't appear to have any DOM of their loaded page.
I can access webObj.html, wh...
I'm building a pretty basic HTML table creator/editor (based on a designMode iframe) at work, using direct DOM manipulation. It's a pain, obviously due to Internet Explorer.
When in designMode, a table inserted into the editing area iframe is resizable and the contents of the cells can be freely edited. In Firefox, rows and columns can ...
I have a following object model:
- Book
-- Chapter 1
--- Page 1
---- Image 1
---- Image 2
---- Text 1
--- Page 2
...
Resources are way down at the page level. But, I need to know the full path to resources, from the resources' point of view.
One way, is to have resources be aware of their parents.
So my Image object could have...
Hi,
I was wondering if anyone has seen this issue before.
I have two button on a webpage. When I navigate away from the page and hit the back button to return the value of one button is placed in the value of the other.
E.g
<input class="SmallData" type="submit" id="logButton" value="Log In" tabindex="93"></input>
<input class="btn"...
I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function.
Currently it's like this:
function conta(Fieldset){
var Inputs = Fieldset.getElementsByTagName("input");
var Selects = Fieldset.getElementsByTagName("select");
/* Doing the stuff I need to do ...
I'm relatively new to Javascript and was wondering if there's a quick way to shuffle content that is contained in multiple <div> tags. For example
<div id='d1'>
<span>alpha</span>
<img src='alpha.jpg'>
</div>
<div id='d2'>
<span>beta</span>
<img src='beta.jpg'>
</div>
<div id='d3'>
<span>gamma</span>
<img src='gamma.jpg'>
<...
Hi Guys,
I am creating a GUI frontend for the Eve Online API in Python.
I have successfully pulled the XML data from their server.
I am trying to grab the value from a node called "name"
from xml.dom.minidom import parse
dom = parse("C:\\eve.xml")
name = dom.getElementsByTagName('name')
print name
This seems to find the node ok but...
I have a container element which I need to resize as its contents change. It contains 2 absolutely positioned divs which can both change height. If I don't specify the height of the container then anything after the container disappears under the contents.
At the moment I am doing the following but I'd be pleased to find a less laborio...
I've been always thinking that DOMNodeInsertedIntoDocument/DOMNodeRemovedFromDocument events should not bubble, and for me that made enough sence. However, just recently I looked into specification once again and found out that in one location it says these events should not bubble (Complete list of event types), while in other location ...
I have html code that looks roughly like this:
<div id="id1">
<div id="id2">
<p>some html</p>
<span>maybe some more</span>
</div>
<div id="id3">
<p>different text here</p>
<input type="text">
<span>maybe even a form item</span>
</div>
</div>
Obviously there's more to it than that, but that's the basic idea....
Hi guys,
Recently I've been doing a lot of modal window pop ups and what not, for which I used jQuery. The method that I used to create the new elements on the page has overwhelmingly been along the lines of:
$("<div></div>");
However, I'm getting the niggling feeling that this isn't the best or the most efficient method of doing th...
This could be a little off the ballpark, but a friend asked me about it and it's kind of bothering me. How do you figure out the current path in your address bar if the server redirects all requests to a default file, say, index.html.
Let's say you entered:
www.example.com/
And your server configuration automatically redirects this r...
Is there a way to access the DOM of the document in an iframe from parent doc if the doc in the iframe is on another domain? I can easily access it if both parent and child pages are on the same domain, but I need to be able to do that when they are on different domains.
If not, maybe there is some other way to READ the contents of an i...
This is not to be confused with "How to tell if a DOM element is visible?"
I want to determine if a given DOM element is visible on the page.
E.g. if the element is a child of a parent which has display:none; set, then it won't be visible.
(This has nothing to do with whether the element is in the viewport or not)
I could iterate thro...
Hi all,
my Code is like
$("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>".replace(/script2/gi, "script"));
ie8 not wirking at all. FF3 is exucuting but page gets blank and seems loading not ending.
someone has a clue?
i want to let pa...
When does script added to the page with Page.ClientScript.RegisterStartupScript() actually run? MSDN states "when the page finishes loading but before the page's OnLoad event is raised" but this isn't much detail.
For example, can a script added with RegisterStartupScript assume the DOM tree has been built? Does the behaviour differ bet...
I need to edit (using javascript) an SVG document embedded in an html page.
When the SVG is loaded, I can access the dom of the SVG and its elements. But I am not able to know if the SVG dom is ready or not, so I cant' perform default actions on the SVG when the html page is loaded.
To access the SVG dom, I use this code:
var svg = do...