JQuery :: Select Portion Of Text Within Node?
Mar 24, 2011Say I have the following HTML:
Code:
<h1> 45 <em>people like this</em></h1>
How do I select just the '45' portion?
Say I have the following HTML:
Code:
<h1> 45 <em>people like this</em></h1>
How do I select just the '45' portion?
let's say I have this code markup:
<div id="id1">
This is some text
<div class="class1"><p>lala</p> Some markup</div>
</div>
What I would want is only the text "This is some text" without the child element's .class1 contents.
How would I do that? A normal selector would select "recursively", so how do I limit it to one level?
I've worked out how to get the value from a select option tag, but can't work out how to get the text inside the option tags. Here is the code I am using to get the value attribute from the option tag..
[Code]...
Highlight a portion of the text and you can search it on the major search engines. The search box can also be used as a conventional search box too....
View 3 Replies View RelatedI have an iframe on a page, i am using a javascript to resize the iframe so that there isnt a scroll bar. However, when I print the page, depending on the browser, different things happen. So far, Google Chrome is the only one that pulls it off... FireFox cuts the page off and doesnt print the last 3 paragraphs and Internet Exploder shrinks a portion of the text onto the right hand side of an A4 page and ignores the last few paragraphs...
View 1 Replies View Related<h1>November<span>2009</span></h1>
making a variable equal the h1 html() without the span text.
// equals 'November2009'
var monthDelete = $('h1').html();
// I need just 'November'
So I have the following xml:<ingredient name="rice"><us>1 cup</us><metric>250 mL</metric> of uncooked Korean rice</ingredient>
I want grab only the "of uncooked Korean rice" part. I tried to use text() but it would grab the text from inside the "us" and "metric" element.
within a function for an onchange-handler ($(...).change(function(e) {...) i tried something like:
$(":parent input[name^=subsequentProperty]", this);
this does not work, but:
$("input[name^=subsequentProperty]", this.parentNode);
does work.
I've seen a variety of implementations around that enable selecting all or no checkboxes by using a checkbox to toggle that choice. However, I'm trying to find a way like this: I have two text links on my page: Select All, and Select None. How can I get those links to call a jquery function to select all or select no checkboxes in my form? As a little food for thought:
<head>
$(function() {
//function for selecting all or none...is there a way to make a single function that passes in a parameter to differentiate between selecting all or selecting none, or do I need a separate function for both?[code]....
I am trying to append to a text node(which is contained in another element) a string but i canot. Here is the code-tell me please where is the error below because i cannot spot it.The containing element is a div class with name calendar, as you can see. Inside the calendar the current month is displayed(not shown here-which i get with the date object), i want to append to the month the test p.
$('.calendar:eq(0)').contents().filter(function()
{
return this.nodeType == 3;
}).append('<p>Test</p>');
I've recently moved over from Protoype and was used to using the update() function to replace text within a node - something like
this:
PROTOTYPE
<p id='dText'>text to be replaced
$('dText').update('New text string')
[code]....
Now it appears to me that in jQuery, there isn't an out of the box function to replace the contents of a node without also replacing the
node too, hence the reason I am chaining remove() and append().
I'm trying to re-export a filtered set of XML data. For an input like this:
<object>
<header />
<thing1>
<value1>1</value1>
[Code].....
However, this currently returns 'undefined'. Is there any easy way to do this, or do I need to actually parse the XML below thing1 and manually write my own XML sub-tree?
Jquery 1.4, Firefox
I have a small question. I am building an AJAX-based content editor and in one portion the following xml tag needs to be processed:<
[Code]...
I'm trying to read a select(dropdown) box from an HTML form along with all its options. My core requirement is to be able to read a select element with all its option and store it in some variable/node using one JS function. Use another JS function to pick the node and convert the values from node back to the options of select box.
We can probably make use of jQuery as well, provided it is supported by IE6.
I have made some application in JavaScript. I need some help from you friends.Whenever i click on some image i want that image should get selected. Same as we select when we drag on it with mouse. Hope u got what i mean.
View 7 Replies View RelatedI'm trying to output the text value from a list node. why it's not working. How do i tell how many childNodes are in the ul element?
Code:
function test(){
var x = document.getElementById("test");
alert(x.firstChild.nodeValue);
[Code].....
I'm trying to add the text value of an xml element to a variable but the closest i can get is having the variable set to [text object] using this method:
rootNode.getElementsByTagName('instructions')[0].childNodes[0];
I have also tried these methods but they always return undefined:
rootNode.getElementsByTagName('instructions')[0].childNodes[0].text;
[code].....
am trying to iterate out the values of an xml file. I have got the file to load though I have not yet been able to extract the values. code...
View 2 Replies View Relatedtrying to read text from text child, basicaly seeking for equvivalent for this:
var groupArray = secondElement.getElementsByTagName("DIV");
// so looking for text nodes
var groupArray = secondElement.getElementsByTagName("??????");
hmm tryed this, seems DOM doesn't see the text node that itself created
// 1.CREATING & filling
imgElement = document.createElement("IMG");
imgElement.src = arrElementsImages[i];
imgElement.setAttribute("style","float:left");
imgElement.style.styleFloat = "left";
firstElement.appendChild(imgElement);
firstElement.appendChild(document.createTextNode("u00a0" + "a"));
//2.TRANSFERING ALL CHILDS TO secondElement
// case1 --> ONLY IMAGE APPEARS !!??
for (i = 0; i < firstElement.childNodes.length; i++)
{
secondElement.appendChild(firstElement.childNodes[i]);
}
//case2 --> TEXT AND IMAGE APEARS
secondElement.innerHTML = firstElement.innerHTML;
I am trying to iterate out the values of an xml file. I have got the file to load though I have not yet been able to extract the values.Considering that theXml is an xml file and 'coords' are tags containing a coordinate how would I extract the value. Here is the code I am using
Code:
var coordTags = theXml.getElementsByTagName( 'coords' );
var len =coordTags.length;///this works
[code].....
var lbl=document.createElement('LABEL');
var txt=document.createTextNode('text');
lbl.appendChild(txt);
in above txt node i want a space infront of that
i tried below, but no use
var txt=document.createTextNode(' text');
any idea ???
I'm trying to read a text file with node.js. This text file is a line of just numbers. I add every line to an array as a string. What I want to do is make it so every element in the array is only one number in the text file. When I use the split function with (" ") it doesn't work correctly; it prints out a string as all the numbers in the text file. how would I delimit this text file with every space or new line.
var fs = require('fs');
var array = fs.readFileSync("10_01.txt").toString().split(" ");
for (var ind = 0; ind<array.length; ind++)
[code]....
Is there a better way to do this because at the moment it doesn't seem to display what I want?
I have an AJAX application using which im attempting to acces a #Text node in the NAME tag of a XML document. i then want to sort the names and place them into tables <td> tag. i can put the names in the <td> but i want them sorted alphabetically. from my understanding im suppose to be able to sort an array simply like this Array[].sort();..............this is the reason i need the text to be an array. Unless you know a simpler way to do this.
Code:
function postNames(){
var signersdoc = xmlHttp.responseXML;
var container = document.getElementsByTagName("td");
[code]....
Code:
<a href="#" onclick="showDistributors('city0','raccoon0','national0',pass link text as variable into the function "showDistributors"); alert(this.text()); return false;">St Albans</a>
How do I pass the distributor name into the function as a variable? I am having trouble finding useful information on "this" method
Im using JQuery with a html framework (YAML) and a content management system (SPIP) and am wondering, since both also come with inbuild IE fixes, especially for the png transparency, is it possible to disable the whole ifixpng portion in JQuery. Apart from it being kinda overkill to use 3 fixes, they dont mix and ifixpng seems to be the one giving me the hardest time (even tho it says it would disable previous fixes already applied, well, or maybe because of that). So can i disable it?
View 3 Replies View RelatedI'm using jsTree-0.9.9a. As a test this is the code i'm using to display the ID
oncreate: function(NODE, REF_NODE, TYPE, TREE_OBJ, RB)
{
if (TYPE === "inside") {
parent_id = $(REF_NODE).attr('id');
alert(parent_id)
}}
This works fine when the parent has no child nodes, however, when a child node exists nothing is returned.