I'd like to store selected text in a variable and then delete the selected text by pressing a button. Preferably with jquery but I don't mind basic javascript.
Thanks in advance.
UPDATE:
Thanks George, I've tried the example that you pointed to stripping down the code to what I need but I can't get it to work on click for the button. ...
I have the following script that creates a div, adds a Google Maps DOM listener, and appends it to another div to another div using JavaScript's built-in DOM manipulation methods:
var div = document.createElement('div');
var html = '<b>' + string_of_text + '</b>';
div.innerHTML = html;
google.maps.event.addDomListener(div, 'click', func...
As a programmer used to developing native applications, I'm expanding my horizons and developing my first web app. I'm intermediate to expert with Linux and C, intermediate with Python and HTML and beginner to intermediate with MySQL and Java.
I'm developing a web app that is more or less a resource allocator for a friend of mine. To pu...
Hi Guys,
I have the follow HTML
<div>This is some <span>special <a href="#">text</a></span> and it's super</div>
And CSS
span {color:#333;}
a {color:#777;}
a:hover {color:#AAA;}
I am wondering what I can use to setup a function that I can extract the color of the <a> and <a>:hover elements?
Thanks
...
I'm writing a Chrome extension to list out the source code for each event handler attached to an <a/> tag when you roll over it.
Currently, I've printed out the href attribute - $(this).attr("href") - and this works fine. The source code is on github at http://github.com/grantyb/Google-Chrome-Link-URL-Extension.
When I extend it to ac...
I am reading a document about HTML5. A few lines down from where I linked, a sample DOM tree is displayed for the sample HTML code given. Why is there no text node directly before the <head> element? Why is there no text node between the DOCTYPE and <html> nodes? Error or feature?
...
Guys,
I need to store the XML that i get it from Google Analytics. Its format is XML file. I need to create the script ( PHP ) that will read XML file from Google Analytics and store in my server with user defined name. I tried like that
<?php
$dom = new DOMDocument();
$dom->load('https://www.google.com/analytics/reporting/export?fmt=1...
I am trying to remove and add similar nodes in a document tree
Element firstItem = (Element) links.item(0);
Element element = (Element)firstItem.cloneNode(true);
int length = links.getLength();
while (0 != length) {
System.out.println("removing element #" + l + " Length: " + length);
Element link1 = (Element) links.item(0);
...
I write the following (DOM) Perl script (shown below) in order to create the following XML DOM:
<books>
<computer/>
</books>
How can I save the XML output into test.xml file? I tried to save the XML with
$doc->printToFile('/tmp/test.xml');
but I get:
can't locate object method "printToFile" via package "XML::LibXML::Document"...
I am working a project currently in which the user can add multiple news headlines and news articles, the number they add is entirely up to the user, for this reason the form they first see only has room for 1 headline and 1 article, to add another article/headline there is a 'button' that has a click event on it, currently I have this i...
I need to do screen scraping and for that i need to convert xml to dom in python please can anybody tell that how can i do this....
...
Is it possible to define a event handler of one type of HTML object so that all the instances of this type of objects have this handler? for example, can I create a function func() as the onclick event handler of input text-fields so that all the input-fields have func() as its onclick event handler?
(it's just something like adding a f...
What I want to accomplish is simple. I want a button's text to change depending on what page your on.
I start this by using the following:
var loc_array = document.location.href.split('/');
Now that I have the url and split it in an array I can grab certain directories depending on the position, like so:
if (loc_array[loc_array.leng...
I am dynamically adding a relatively large number of small images to a page. I make a XMLHTTP request which returns some JSON data of the form
{images:[
{url:'/image?id=1',
width:32,
height:32,
label:"Foo"},
{url:'/image?id=2',
width:32,
height:32,
label:"Bar"},
....
]}
I then construct some HTML of the form
<ul>
...
I'm looking for a nice way to mark/select all elements between two selected elements.
Imagine
<parent>
<p>...</p>
<p>...</p>
<p>...</p>
<p>...</p>
</parent>
There's a click handler on parent. The user now can select two p element in this list an then all p-elements in between should get 'activated'.
I'm thinking about a sy...
I have a situation where I want to massage an XML string into an easier format to handle. In a previous project I've found that transforming into
<action>
<set key="A" value="X" />
<set key="B" value="Y" />
...
</action>
works very well for our purpose. My problem is with extracting the key-value pairs programatically inside Ja...
Hi,
Sorry if the question is too general, but I wonder what is the use of a PHP DOM Manipulation compared to javascript DOM Manipulation?
I understood that it was mainly used to parse some html, or xml, but are there other applications where it is good to use?
Thanks :)
...
I am trying to solve a problem for a client where they want to dynamically inject an image into the page and have it call their js function when clicked. The script is included from our base js class to their site, so it's my code on their site essentially.
I am very close to getting there, but I've found a strange issue in IE of all pl...
I'm doing something like:
<p>SQL</p>
<p>sql</p>
<p>sQl</p>
<p>SqL</p>
<script type="text/javascript">
var ps = document.getElementsByTagName('p');
for(var i = 0; i < ps.length; i++) {
var p = ps[i];
p.childNodes[0].nodeValue.replace(/sql/gi, 'VB.NET');
p = null;
}
</script>
But it's not replacing the text. What's wrong?
Thank you....
It's my first time parsing XML and I don't really know what I'm doing at the moment. Here's my XML:
<?xml version="1.0" encoding="UTF-8"?>
<MyDocument xmi:version="2.0">
<Thingamabob name="A" hasDohicky="//@Dohicky.0">
<Dingus/>
</Thingamabob>
<Dohicky name="B"/>
</MyDocument>
So what is "//@Dohicky.0" called? I understand...