textnode

HTML Javascript get textNode by id tagname anything?

自闭症网瘾萝莉.ら 提交于 2019-12-05 15:45:10
Is there anyway to assign an id to a textNode and then retrieve that text node via that id? I've tried several different ways and keep getting errors saying cannot get property of null. My code looks something like this... var myDiv = document.createdElement('div'); myDiv.id = "textContainer"; var textNode = document.createdTextNode("some text"); textNode.id = "descriptionText"; myDiv.appendChild(textNode); Works fine to this point; it displays on the page. Later I try to modify that text node and that's where I'm getting the errors. var tempNode = document.getElementById(descriptionText);

How can I use php to remove tags with empty text node?

≯℡__Kan透↙ 提交于 2019-12-05 08:06:33
问题 How can I use php to remove tags with empty text node? For instance, <div class="box"></div> remove <a href="#"></a> remove <p><a href="#"></a></p> remove <span style="..."></span> remove But I want to keep the tag with text node like this, <a href="#">link</a> keep Edit: I want to remove something messy like this too, <p><strong><a href="http://xx.org.uk/dartmoor-arts"></a></strong></p> <p><strong><a href="http://xx.org.uk/depw"></a></strong></p> <p><strong><a href="http://xx.org.uk/devon

finding elements with text using jQuery

孤人 提交于 2019-12-05 04:58:25
I want to create an array of all the html elements within a div that contain text strings, such as <p>some string</p>. I don't want to get hold of the strings, I want the array items to be the elements (in the example, would be the p node). I do not know before hand what the strings will be, so I can't look for string values to match. I also don't want empty text nodes to end up in the array. Thanks! $("#my_div *").filter(function() { var $this = $(this); return $this.children().length == 0 && $.trim($this.text()).length > 0; }) This version will not return parent elements that contains the

When a mousedown and mouseup event don't equal a click

匆匆过客 提交于 2019-12-04 02:37:21
I've been using some buttons for a while now that have a depressed effect as they are clicked using position relative and a top: 1px in the :active pseudo-class. I had problems with click events not firing and it turned out to be due to the mousedown and mouseup events not firing on the same element. I did a bit of fiddling to make sure the inner-most element covered the whole button and discovered that the issue remained. If I click right at the top of the text then the link jumps down (firing the mousedown event) and then back up (firing the mouseup event) but the click does not occur. If I

How can I use php to remove tags with empty text node?

陌路散爱 提交于 2019-12-03 23:10:29
How can I use php to remove tags with empty text node? For instance, <div class="box"></div> remove <a href="#"></a> remove <p><a href="#"></a></p> remove <span style="..."></span> remove But I want to keep the tag with text node like this, <a href="#">link</a> keep Edit: I want to remove something messy like this too, <p><strong><a href="http://xx.org.uk/dartmoor-arts"></a></strong></p> <p><strong><a href="http://xx.org.uk/depw"></a></strong></p> <p><strong><a href="http://xx.org.uk/devon-guild-of-craftsmen"></a></strong></p> I tested both regex below, $content = preg_replace('!<(.*?)[^>]*>\s

java dom getTextContent() issue

南楼画角 提交于 2019-12-02 05:29:29
问题 when i'm trying to access my xml data from doGet method of my servlet, it only outputs the value up to the white spaces, including the whole value. XML File: <RealEstate> <Property> <Type>Apartment</Type> <Bedrooms>2</Bedrooms> <Bathrooms>2</Bathrooms> <Suburb>Bondi Junction</Suburb> <Rent>1000</Rent> </Property> </RealEstate> I then call up the Suburb from a Java Servlet in doGet : Node suburb1 = doc.getElementsByTagName("Suburb").item(i); out.println("<tr><td>Suburb</td>" + "<td>"+suburb1

java dom getTextContent() issue

喜夏-厌秋 提交于 2019-12-02 01:50:21
when i'm trying to access my xml data from doGet method of my servlet, it only outputs the value up to the white spaces, including the whole value. XML File: <RealEstate> <Property> <Type>Apartment</Type> <Bedrooms>2</Bedrooms> <Bathrooms>2</Bathrooms> <Suburb>Bondi Junction</Suburb> <Rent>1000</Rent> </Property> </RealEstate> I then call up the Suburb from a Java Servlet in doGet : Node suburb1 = doc.getElementsByTagName("Suburb").item(i); out.println("<tr><td>Suburb</td>" + "<td>"+suburb1.getTextContent()+"</td></tr>"); and it only outputs "Bondi" instead of "Bondi Junction" Does anybody

Is there an alternative to jQuery / sizzle that supports textNodes as first class citizens in selectors?

一笑奈何 提交于 2019-12-01 07:28:31
问题 I've discovered that I have a need for selectors with full support for DOM textNode s that jQuery doesn't provide. jQuery ignores text nodes, probably because most pages have tons of irrelevant blank ones between tags that the various browsers can treat differently. Most answers to jQuery questions about text nodes come down to using the .contents() function which returns all the child nodes for the selected items, including text nodes - all other jQuery APIs ignore text nodes. Often you don

How can I replace a Java Jackson TextNode by another one (update)?

这一生的挚爱 提交于 2019-11-30 16:45:56
问题 My goal is to update some textual fields in a JsonNode. List<JsonNode> list = json.findValues("fieldName"); for(JsonNode n : list){ // n is a TextNode. I'd like to change its value. } I don't see how this could be done. Do you have any suggestion? 回答1: The short answer is: you can't. TextNode does not expose any operations that allows you to alter the contents. With that being said, you can easily traverse the nodes in a loop or via recursion to get the desired behaviour. Imagine the

jQuery get .text() but not the text in span

若如初见. 提交于 2019-11-30 08:57:54
Hi guys this is my jQuery part that makes my menu for my pages. function fetchmenus() { $.getJSON('sys/classes/fetch.php?proccess=1', function(status) { // get line status $.each(status, function(i, item) { if (item.id == "1") { active = "class='active'"; lastpageid = item.href; } else { active = "class='nonactive'"; } $('<li id="' + item.href + '" ' + active + '><a href="#' + item.href + '">' + item.menuTitle + '<span class="menuspan" id="' + item.href + '"></span></a></li>').appendTo('#menuarea ul#mainmenu'); }); }); } What i want to do is get the item.menuTitle in the <a but before the