FAQ Database Discussion Community


Express and Cheerio/JSDOM

javascript,node.js,dom,express,cheerio
I am trying to get Cheerio to work with Express. I'd like to be able to manipulate the dom from the server, but all I have found is web scraping.. There are some requirements.. At the moment, I am able to run multiple app.listen(port); statements, and use multiple servers. I'm...

Using jquery to auto populate only a time input & not other buttons

javascript,jquery,html5,dom,jquery-plugins
I am trying to use jquery to auto populate an input time field. It works fine; but it applies the time to my other button. How do I only refer it to my input type time field? Any help is most appreciated. Thanks HTML <input type="time" value="" /> <input type="button"...

Unable to execute javascript loaded from external html page

javascript,jquery,html,dom
I am trying to execute 3 javascript commands on the page http://ringvaart.toervolger.nl/nl/tour_2/livepagina/?mode=default by loading it into my own div, but I fail to execute the commands. The commands toggleAllSelected(); setActiveTeamId(64); toggleSelectedTeamId(40); are able to execute on the original page, but they are not defined in my own javascript and I...

How to use DOMParser in PhantomJS?

javascript,dom,phantomjs
The following snippet works correctly and returns a Document node in Firefox, Chrome and Safari web consoles. However, it returns null in PhantomJS 1.9.8. (new DOMParser()).parseFromString("<div></div>", "text/html"); Any idea why this is returning null? ...

How can I get the text style from window.selection()?

javascript,html,css,dom,selection
I'm trying to get the css style of the text selection when user select only 1 row. This is my code which works for multiple lines selection case: var selectedDivs = window.selection().getRangeAt(0).cloneContent().children // Then I can get css style from selectedDivs But for single line selection, the selectedDivs is always...

Mapping XML nodes into HTML form elements

javascript,jquery,html,xml,dom
I'd like to map XML node values (XML sent from AJAX script) into corresponding HTML form elements. So for example, an XML data; <object> <fielda>John</fielda> <fieldc>Tailor</fieldc> </object> should be inserted by script into HTML form: <form name="myform"> <input name="fielda" value=""> <input name="fieldc" value=""> </form> The catch is that script should...

virtual-dom - how to get hold of real DOM element in order to integrate with spin.js?

javascript,html,dom,spin.js,virtual-dom
When using the virtual-dom library, how can I get hold of the real DOM element corresponding to a virtual one? The use case is I need to manipulate the DOM via the spin.js library. Correspondingly, in React you would call React.findDOMNode in order to get hold of the element to...

Comparing the InnerHTML of an object in jQuery

javascript,jquery,dom,comparison,sharepoint-2013
I am able to get the .html() of a SharePoint textbox, which in the DOM simply appears as a <div>. When the textbox is empty, the InnerHTML of that <div> simply appears as <p></p>. Because this particular textbox does not always appear (I control its appearance based on the selected...

DOM XML child nodes

php,xml,dom
If i have an XML for example like this: <?xml version="1.0" encoding="utf-8" ?> <parent > <child> <grandchild> </grandchild> </child> </parent> And i want to get all the children of the parent node (using php for example), when i call $xmlDoc->loadXML('..'); $rootNode = $xmlDoc->documentElement; $children = $rootNode->childNodes; what would $children contain?...

QDomDocument toString

xml,dom,qt5
Running the below code does not produce the same ordering of attributes each time. Why is this happening? QDomDocument dom; QDomElement element= dom.createElement("MyElement"); element.setAttribute("attr1", "foo"); element.setAttribute("attr2", "bar"); element.setAttribute("attr3", "hello"); dom.appendChild(element); QString text = dom.toString(); I am aware that the xml specification says ordering of attribute is not significant but I...

How to append the text (increasing order) using DOM parser in PHP?

php,html,dom,domxpath
$html='<h1 class="title">Exponents[label*exponents]</h1> <h2 class="title">Exponents[label*exponents]</h2> <h2 class="title">Exponents[label*exponents]</h2> <h1 class="title">Exponents[label*exponents]</h1> <h2 class="title">Exponents[label*exponents]</h2> <h2 class="title">Exponents[label*exponents]</h2> <h2 class="title">Exponents[label*exponents]</h2> <h3 class="title">Exponents[label*exponents]</h3> <h1...

Can't locate module(s) using Mojo::DOM

perl,dom,mojolicious,mojo
I'm new to Mojolicious. I am sure this is probably a setup problem, but it's eaten up an entire day of my time. I'm trying to run this simple test code #!/usr/bin/perl use strict; use warnings; use Mojo::DOM; use Mojo::UserAgent; my $ua = Mojo::UserAgent->new(); $ua->get('http://stackoverflow.com/questions/26353298/find-links-containing-bold-text-using-wwwmechanize')->res->dom('a div')->ancestors('div.spacer')->each( sub { say $_->all_text...

Selecting a Particular class inside another class and getting the inner html from a DOM using javascript

javascript,dom
I am stuck with this thing.May be an immature question.I dont know,I am pretty new to programming.I want to get a particular elements inner html from DOM of the page.The problem is the page is so complex it has so many classes subclasses href,span and all kind of things.Here is...

Updating the DOM with change in an object (vue.js) - binding not working?

ajax,dom,vue.js
I have the app.js file where gmarkers is an array of objects : var vm = new Vue({ el: '#lili', data: { listings: gmarkers } }); In my HTML file : <div id="lili" > <div v-repeat="gmarker : listings" class="listing listing-list col-sm-12" style="height:50px;line-height:50px;" data-cat="@{{gmarker.mycategory}}" data-id="@{{gmarker.id}}" > <span style="color:black;"> <a target="_blank" href="@{{gmarker.listlink}}">...

input value undefined javascript

javascript,css,dom,browser
I want to show an error message when text box is empty on submit, but is not working and everytime I try to get the value through the console area returns undefined. CSS <style> #error_alert { visibility: hidden; border: 1px solid #F00; text-align: center; width: 100px; } label, input, button...

ReactJS dealing with server-side loaded DOM

dom,reactjs
I'm just about to experiment with reactjs I'm new to it. Is reactjs capabile to add a component to existing DOM. So I have already server-side created DOM and on the flow reactjs should add a component which should render inside body but keep what already is there. <script type="text/jsx">...

Showing and hiding divs on click

jquery,html,css,dom
I have a nav bar with 3 menu points. called "home" "bildformate" and "kontakt". On load the a div with the class "home" is displayed below the navbar, displaying text etc. The other 2 divs are hidden. When I click on "bildformate" I want the home div to disappear and...

iMacros TAG to Find TXT and Click Nearby (previous) Link

javascript,dom,web-scraping,scrape,imacros
Below is the example code of Wordpress Backend tag management section. I'm trying to write an iMacros to find a tag and delete it. However the Tag text doesn't below in any HTML's tag. <div class="tagchecklist"> <span> <a id="post_tag-check-num-0" class="ntdelbutton" tabindex="0">X</a> &nbsp;Orange </span> <span> <a id="post_tag-check-num-1" class="ntdelbutton" tabindex="0">X</a> &nbsp;Apple </span>...

Is there a way to know which 1 of 3 (or more) slideshows is active?

javascript,jquery,dom
I am wishing to be able to turn off the active slideshow and turn on the user chosen one from a button. I had thought to just use the code: $('div.nivoSlider:not(#c' + id + ')').data('nivoslider').stop(); One statement to turn off all sliders. Or use: $('#c1').data('nivoslider').stop(); $('#c2').data('nivoslider').stop(); $('#c3').data('nivoslider').stop(); The problem is,...

Rows-Element, where are these whitespaces coming from?

javascript,html,dom
First: My problem is that by inserting strings into several fields of a form from a row via DOM, the values occure with a lot of whitespaces, both at the beginning and the end. What I want to do: look up the values of the cells in the row I...

Undefined when passing DOM object in Javascript

javascript,html,dom
I am (attempting) to have a table which can switch the background color based on an RGB value, where each row of the table has clickable <td>s, and they will add up to give and RGB value (eg. first row is +/- 123, second row is +/- 123. #2: The...

Appending the contents of a HTMLCollection to Body

javascript,html,dom
I am trying to: Parse a HTML string to a DOM object Extract the paragraphs (10 of them in this case) Append extracted paragraphs to body I have the following code: $(document).ready(function(){ function _parse(html_str_or_obj) { var elem_obj, elem_dom_obj; //Convert to DOM element elem_obj = document.createElement("div"); elem_obj.innerHTML = html_str_or_obj; elem_dom_obj =...

Loop nested nodes in Symfony Crawler

php,symfony2,dom
How to loop through all nodes of Dom. I use latest Symfony Crawler. Simple example: <?php function test() { $crawler = new Crawler($html); $crawler ->filter('body > ul') ->each(function (Crawler $node, $i) { loop($node); }); } function loop(Crawler $node) { static $counter; if ($node->filter('ul')->count() > 0) { loop($node); } $counter++; echo...

Is it possible to make querySelectorAll live like getElementsByTagName?

javascript,dom,css-selectors,getelementsbytagname,queryselectorall
getElementsByTagName() has 2 great features: it is fast and it is live. But what if I want to get p strong. Of course I could refine a selection using getElementsByTagName() again but wouldn't I loose the live effect for the new p tags? Is there a way to turn querySelectorAll...

First getElementsByTagName() returns all elements in HTML (Strange behaviour)

php,wordpress,dom
I am using PHP to parse HTML provided to me by Wordpress. This is a post's PHP returned my Wordpress: <p>Test</p> <p> <img class="alignnone size-thumbnail wp-image-39" src="img.png"/> </p> <p>Ok.</p> This is my parsing function (with debugging left in): function get_parsed_blog_post() { $html = ob_wp_content(false); print_r(htmlspecialchars($html)); echo '<hr/><hr/><hr/>'; $parse = new...

How can I hide any DOM element

jquery,dom
I want to hide any element that is clicked. For example, if <p></p> is clicked it should hide, or if <div></div> is clicked it should hide. I tried using: $(document).ready(function(){ $("*").click(function(){ $(this).hide(); }); }); However, this hides all the elements if one element is clicked. How can I achieve what...

Adding an Image to HTML Based on Outcome of If/Else (innerHTML? DOM?)

javascript,html,dom
I'm doing a basic rock paper scissors game in Javascript, nothing new but I'm trying to fancy it up a little. All of the ones I see just output what the computer selected in plain text via innerHTML and that's fine but I want it to show an image based...

how to properly adjust XML hierarchy of nodes [closed]

php,html,dom
I want to create a xml file by using html form. i am able to create a xml file ... but while some hirarchy come that time it is giving error. please check my code or update it. below is output which i want. output :-<url>TODO</url> <licenses> <license> <name>TODO</name> <connection>TODO</connection>...

How the structure of a web page using PHP and works [closed]

php,dom
I'm arriving in PHP world just now. By the experiments I'm doing, I'm making some assumptions: 1- A PHP script is launched when the file it resides on is requested via http. 2- The script creates an independent scope for it's vars. 3- The script can only access any other...

FastDOM - Read / write every 17ms?

javascript,dom,optimization,asynchronous,requestanimationframe
FastDOM - a small library that batches DOM reads & writes into raf (requestAnimationFrames). https://github.com/wilsonpage/fastdom I have read the code, however, I am struggling to understand how it works. Here are a few presumptions we have: - Browsers are generally set to 60fps - So in total, there can be...

Make sure image has loaded before do something with jQuery

jquery,dom
I have a gallery on my app. There are plenty of thumbnails that fadeOut to make room for new thumbnails. I know I can preload it on another div, set a timeout and then change the thumbnail src to the preloaded one. But, it does not guarantee that the image...

Get an HTML element's line number

html,dom,element,codemirror,ace-editor
Was wondering if there is a better way to find an elements line number in the sources code. This is what i've go so far: // Get the item that the user is clicking on: var focused = doc.getSelection().anchorNode; if(focused.nodeType == 3){ // text node focused = focused.parentNode; } //...

Capitalize the HTML

javascript,html,css,dom
I am trying to Capitalize the HTML selected Attribute, but does not work ! <option value="${city}" style="text-transform: capitalize"> ${fn:toLowerCase(city)}</option> ...

How to find and check all dynamic child checkboxes in tree using jquery?

javascript,jquery,dom,dynamic,tree
I have added check-boxes dynamically to all the element and successfully added the functionality to select all checkboxes but not able to do the selection for the parent child checkboxes in tree structure means if i select the "Asia" it should select all "Estern Asia" and "Southern Asia", if i...

CsQuery - Unwrap element with whitespace character between

html,vb.net,dom,csquery
I'm trying to unwrap a string in CsQuery. The functionality works, but I want to add a whitespace char between each tag. Dim fragment = CsQuery.CQ.Create(<div>some text</div><div>More text</div>) Dim unwrapTags = New List(Of String) With {"div"} For Each s In unwrapTags fragment(s).Contents.Unwrap() 'Here I want to add a whitespace between...

Dynamically adding HTML via javascript

javascript,jquery,html,html5,dom
Good Day, I have an ASP.NET MVC app that I'm working on and have a partial view with one row of data. <div class="row paymentRow"> <div class="col-xs-4">Additional Invoices</div> <div class="col-xs-8"><input type="text" style="width: 100%"/></div> </div> I have a button that when clicked, it adds additional rows to the DOM after the...

Eloquent Javascript: DOM Animation snippet

javascript,animation,dom,recursion,requestanimationframe
I'm trying to understand everything that is happening in this little code example in Eloquent Javascript: The Document Object Model (Chapter 13), but I'm not clear on where exactly the value for "time" is being passed into the animate() function before the function itself gets passed into requestAnimationFrame(). What exactly...

Scala.js: Selecting and manipulating generated SVG

jquery,scala,dom,svg,scala.js
I'm struggling with something seemingly simple. Using Scaja.JS, I have generated some SVG with the ScalaTags library. I now wish to manipulate the SVG elements using events: circ.onclick = { e: dom.MouseEvent => ... } Specifically, I want to select all elements of a certain class and then toggle some...

Detect if directive was removed from DOM

javascript,angularjs,dom,angularjs-directive
I have an AngularJS directive and I need to perform certain actions if the directive's element is removed from the DOM (either from inside an AngularJS call or by any other method, like jQuery). Is that possible?...

How to use a loop counter to modify values for a hyperlink constructor

javascript,html,dom
What I'm trying to do is while using a for loop, use the loop counter i to modify values that already have a base number assigned to them in a html element. This is so i can construct multiple hyperlinks with different values. To elaborate here is my html code...

how to change specific node value in xml using Dom php

php,xml,dom
Hi i want to change the value of cost to $6.0 where the color of cupcake is Red. how can i achieve that..here is my two sample cupcake though i have many cupcake in my xml file..so i want to first find the cupcake whose color is red and then...

Safely query size of element soon after inserting it to DOM

javascript,dom,browser
Is there an way (maybe an event?) to delay querying the height of element until all of the styles for it have been fully calculated, so that I know that it's height is calculated properly? In my app I need to get the height of an element as soon as...

jquery click event won't trigger

javascript,jquery,html,dom,bootstrap
In the following html, javascript, bootstrap form the click event handler works properly and adds a new dynamic row but the remove button does not alert out anything when clicked on it. There are no error messages on the debugger console so i am not sure what's wrong. <!DOCTYPE html>...

How to detect wake from sleep in the browser on iOS/Android?

javascript,android,ios,dom,browser
I want to be able to refresh the page when the user returns to page from a different tab or by waking the device. I could have sworn that I read somewhere that the pageshow event would be fired from the window, but that turns out not to be the...

How to expand/collapse (+/-) for a nested dynamic list using jquery

javascript,jquery,dom,toggle
i have tried the toggle function but i think selecting a the proper list is having some problem. var json ={"Asia": [{"regionList": [{"regionName": "Eastern Asia","Countrylist": [{"countryName": "China","subCountryList": [{"subCountryName": "Southern China"},{"subCountryName": "Eastern China"}]},{"countryName": "Hong Kong"}]},{"regionName": "Southern Asia","Countrylist": [{"countryName": "India"},{"countryName": "Pakistan"}]}]}]}; var html = ''; $.each(json, function(i1, object) { html += '<li><input...

Remove a noscript tag inside the head tag with JavaScript

javascript,dom
I am trying to remove a <noscript> tag with JavaScript. But every attempt so far has failed. I tried these: // The noscript tag has a id. I'm accessing it over this id var noscript = window.document.getElementById("noscript_with_id"); noscript.parentNode.removeChild(noscript); // noscript.parentNode is null noscript.outerHTML = ""; // doesn't do anything noscript.innerHTML...

How to wrap the elements by div according to the elements tree structure?

php,html,dom
I have been doing this for 2 days with no luck. I tried in both using Dom parser class and loop method but both of them confusing a lot and couldn't get a solution. Objective: I need to wrap h tags with div. Parent-child relationship is like h1->h2->h3 and so...

Is it possible for me to achieve the equivalent of “display: none” but have the element still in the DOM?

javascript,jquery,html,css,dom
My situation is the following. Today I decided that I wanted to make my site more mobile-friendly. My site uses tables in several places. Because those are difficult to fit onto a mobile device if they have more than a couple columns, I decided to hit a couple columns with...

add a tag before img via php dom

php,dom
hi with this php dom code I change img attributes: foreach ($imgs2 as $img) { $img->setAttribute('src', $newsrc); $img->setAttribute('alt', 'hi'); $img->setAttribute('width', $Size); } Is it possible to add an 'a' tag with href content of $newsrc with dom? for exampple: this is my current result: <img alt="hi" src = "pic1.png" />...

Trying to get just the text from a node with filter(), but is returning an object?

javascript,jquery,dom,text
I am simply trying to extract the text without any of the elements from a DOM node with var textIWant = $('.classname').contents().filter(function(){ return this.nodeType === 3; })[1]; This returns to me what looks like a string in the console, something untrimmed like.. " text I want " so when I...

What does this line do? (xml2json conversion in javascript)

javascript,json,xml,dom,nodelist
Hi I have found a method on-line for converting XML to JSON. I have been using it for a bit and it works well. Now I need to modify it to meet my specific needs but modifying it is difficult because I do not completely understand what this method is...

Javascript set Attribute

javascript,html,ajax,dom
I have a problem. I want to set some attributes with JS. for(i=0;i<div_navi.childNodes.length;i++){ if(div_navi.childNodes[i].nodeName =="SPAN"){ div_navi.childNodes[i].setAttribute("onclick","getContent(div_navi.childNodes[i].textContent); div_navi.childNodes[i].style.cursor ="pointer"; } if(div_navi.childNodes[i].nodeName =="A") div_navi.childNodes[i].setAttribute("href",div_navi.childNodes[i].textContent); } } I want to set a parameter in getContent, but it doesn't work. Has anybody an idea, how this could work?...

Simple HTML DOM: accessing html elements within results

php,html,dom
I'm trying to get a better understanding of PHP Simple HTML DOM and am kinda stuck on the following. I am trying to retrieve information from one of my user pages by using the following code : $dom = file_get_html('http://127.0.0.1/comments/top-commenters/'); foreach($dom->find('tr[id*=commenter]') as $result) { print_r($result->innertext); } Which produces for each...

Modify existing XML, adding and deleting nodes java

java,xml,dom
Existing XML <ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2013-08-01"> <OperationRequest> <Arguments>xyz</Arguments> </OperationRequest> <Items> <Item> <ItemId>123<ItemId> <CustomerReviews> <IFrameURL>someurl</IFrameURL> <HasReviews>true</HasReviews> </CustomerReviews> <EditorialReviews> <Content>text</Content> </EditorialReviews> <Item> </Items> Need to...

Select2: Prevent Select2 dropdown from getting focused on click

javascript,jquery,html5,dom,jquery-select2
How can we prevent a disabled Select2 dropdown from getting focused on click. It is well prevented from getting focused on pressing 'TAB' key. I've already tried adding tabindex='-1' to various div elements in Select2's hierarchy. None helped. For example, refer this link to go to their documentation page and...

getAttribute by TagName - JS

javascript,dom,getattribute
My specific situation is that I'm trying to remove/make inactive a link element from the DOM (I have no control over it being generated). The way that I plan to do this is through replacing the 'href' attribute with a nonsense value - the reason I've chosen to do it...

Delete Javascript Element in Runtime [duplicate]

javascript,dom
This question already has an answer here: JavaScript DOM remove element 3 answers I have this code below: <div id="myid_info_barcode" class="myid_print_duo_barcode"> <canvas width="256" height="256"></canvas> </div> I want to delete the canvas in runtime. How will I do that in Javascript?...

innerHTML in DOM

javascript,dom,innerhtml
I am unable to change the text inside my 'p' tag using this script <script> var firstItem = document.getElementByTagName('p'); firstItem.innerHTML = 'Adding Javascript'; </script> ...

Accessing 'this' table cells value

javascript,dom,javascript-events
I have a form, after form has been filled and add button pressed - all the values from the form get to PouchDB and then into the table in the browser. I need to make an "edit" option. The idea is: <td ondblclick='updateVaucher()' style='cursor: pointer'>"+data[i].doc.vaucherID+ "</td> Now the question is:...

Get a link from many matching links on a page?

php,html,dom
I am grabbing the HTML of a remote page with file_get_contents(), and in this remote page there are loads of links I can grab with a $dom. However the problem I'm having is the link I want contains a specific value '/vue/', and there are anywhere from 1 to 1000...

PHP DOM Document ignore whitespaces appending nodeValue

php,dom,docx
I'm working with MS Office Word document through PHP and DOM. I am adding paragraphs to my document. And now I have to make the part of string bold (it becomes from database and I'm unable to change it). Like this: The part of string is bold really. What I...

How to use JavaScript to Alter CSS for Multiple Elements

javascript,css,twitter-bootstrap,dom
I am trying to use JavaScript to change the background color of an element after being selected, and also to make sure that only one element at a time has the particular background color. Once the user selects on a different element I would like the previous element that was...

jQuery's .get() stole my elements. Ok, but why?

jquery,dom,methods
So I have been brushing up on my jQuery and have been playing with the .get() method. I understand that you can use it to put DOM elements into an array like $('p').get(); and then access their properties for example console.log($('p').get(0).innerText);. But I also noticed that when I tried to...

how to remove one image in string via php dom

php,dom
I have an string with some <img> in it. $string = ' <img src="pic.jpg"> and <img src="pic2.jpg">'; $doc = new DOMDocument('1.0', 'UTF-8'); libxml_use_internal_errors(true); $doc->loadHTML(mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8')); libxml_clear_errors(); $imgs = $doc->getElementsByTagName('img'); foreach ($imgs as $img) { if($img->getAttribute('src') == 'pic.jpg') { // I want delete that picture form string $img->parentNode->removeChild($img); } else...

Why my meteor app create “hiddendiv common” div tags?

javascript,html,dom,meteor,materialize
I'm wondering why my meteor app create some tags like this for no reasons? <div class="hiddendiv common"></div> Thank you...

Why is this code not performant? Updating inner text vs replacing entire tags

javascript,jquery,dom
Can someone explain why this code isn't working. If you click the cats quickly, it freezes the browser. render: function(catName){ var cat = controller.getCat(catName); var displayArea = $('#displayArea'); var catImage = $('#catImage'); var num = $('#numClicks'); // the two lines below are not performant catImage.attr('src', cat.url); num.text(cat.numClicks); // the three...

Fetch url-data attribute using simple html dom

php,html,arrays,parsing,dom
My concern is to extract links from a div using php html dom library. code exemple : include("simple_html_dom.php"); $html=' <div id="base" url-data="http://www.domaine.com/page?user=username"></div> <div id="base" url-data="http://www.domaine.info/page?user=username"></div> <div id="base" url-data="http://www.domaine.org/page?user=username"></div> <div id="base" url-data="http://www.domaine.net/page?user=username"></div> <div id="base"...

Jquery Loop appending image element just appends once

jquery,loops,dom
I'm trying to append an image element multiple times trough a loop, but it is only appearing once, any idea why? Here is my code $(document).ready(function() { var myImage = new Image(); myImage.src = 'image.jpg'; for(i=0; i < 12; i++) { $('#photos').append(myImage) } }); ...

get submitted values with PHP DOM

php,dom,submit
I want to get the values that belong to the answers of a test. There could be any number of questions. A question has the HTML: <form method='post' action='calificar.php'> <div class='pruebaAlumno'> <h5>Pregunta 3</h5> <h3>¿Que factores definen la capacidad de una persona?</h3> <input type='checkbox' name='respuestaAlumno[]' value='Voluntad'> Voluntad <br> <input type='checkbox' name='respuestaAlumno[]'...

How can I swap two id's between 2 html elements?

javascript,jquery,html,dom
Let's say I have this page structure <div id="line-value-container-1-1"> <button type="button" id="up_value_1_1"> <span class="icon-chevron-up"></span> </button> <button type="button" id="down_value_1_1"> <span class="icon-chevron-down"></span> </button> </div> <div id="line-value-container-1-2"> <button type="button" id="up_value_1_2"> <span class="icon-chevron-up"></span> </button> <button type="button" id="down_value_1_2">...

Why DOM came into picture? [on hold]

dom
I understand DOM is document object module which is used for create and modify html document or xml document but what exactly DOM will do? IF DOM is not there then what will happen?...

Changing DOMNode tag name creating anomalies within the saved HTML

php,wordpress,dom
In the process of making a Wordpress post parser for my personal website but hitting some behaviour I can't explain. Here's the code: // Wordpress uses <p></p> sections for new lines $sections = $doc->getElementsByTagName('p'); foreach ($sections as $section) { $hasChilderen = $section->hasChildNodes(); $contents = $section->nodeValue; // If we have text,...

Document innerHTML shows old content, on ajax load

javascript,ajax,dom
$.ajax({ url: "/path/to/dynamic/html", type : "GET" }).done(function(result){ $("#content").html(result) setTimeout(function(){ console.log("Now, the html content is " + document.body.innerHTML )}, 10000) }) /path/to/dynamic/html url returns a plain string as, i am the dynamic content After an expiry of 10 seconds, i expected the console to print, <div id="content">i am the dynamic content</div>...

jQuery Make Text Change Before It's Noticeable

javascript,jquery,html,dom,text
I'm using the following code to make a text change on a website: jQuery(document).ready(function() { jQuery('div#sidebar ul.side-nav li.current_page_item a').text('Request a Quote'); }); The problem is, the change is done until AFTER the webpage has finished loading, so the user actually gets to see what was the original text before the...

PHP getElementsByTagName Scraping Links on Webpage Need to Determine if they contain Img elements

php,dom,domdocument,getelementsbytagname,getattribute
So I'm building a custom scraper for a project. I can currently scrape all of the links on a webpage, storing the HREF and anchor text in a database. However I am getting stuck when trying to determine if the anchor element contains and image element. Here is my code:...

Peculiar behavior on the far right side of

javascript,html,css,dom
I'm trying to implement a custom context menu and this means I have to take care of the edges of the container (so that the menu doesn't appear outside of visible boundaries). So far, my simple proof-of-concept works but there's some weird interaction between the conditionals for checking if the...

Find

that contains image(s) and change style of that

php,dom
I'm parsing Wordpress post HTML through PHP. I want all images to be centered. This alone is easy enough, however, I also want images on the same line to be centered together. In order to do this I need to apply the attribute class="image-content" to the <p> block. How do...

Dynamic update of dom-repeat templates by changing the underlying array

javascript,dom,polymer,polymer-1.0
Is there a Polymer dom api method or other ways to automatically update the repeated template with additional elements, should the underlying array gets updated? I have a dynamic array that gets updated through ajax calls repeatedly. This array keeps changing its length (elements get incrementally appended or removed based...

Invoke a custom method on a DOM element

javascript,jquery,dom,methods,invoke
I want to invoke a custom method on a DOM element like this : <div id="MyObject"> <!-- some elements --> </div> <script> function doSomething() { // do something with input DOM element } $("MyObject").doSomething(); </script> How can I develop this problem? Is it necessary to use jQuery or not?...

SVG styling issue occurs second time onwards : chrome only

javascript,google-chrome,dom,svg
This is a weird issue. I am having a SVG on my page function addClone() { //loadXMLDoc(); var svg = document.getElementById("svg"); var selected = document.getElementById("ID_obj8e530fe7-9e8b-474e-a48b-9c26418b84a6"); var targetElement = selected.cloneNode(true); var namespace = "http://www.w3.org/2000/svg"; var dummySvg = document.createElementNS(namespace, "svg"); dummySvg.appendChild(targetElement); svg.appendChild(dummySvg); //Doing my stuff here with newly appended dummy element. debugger;...

Call a bound function within a Directive from an ng-click

javascript,html,angularjs,dom
I was wondering I am able to call a bound function within a directive when part of a div is clicked. I currently have a div with another div inside that serves as a button to expand the div. The large div has a directive that makes it expandable. I...

In Angularjs, how do I review the DOM after a route change?

javascript,angularjs,dom
In my app I use ng-view to switch out my views. I need to manipulate elements such as change width and position. When I try to do it with on my controller I'm getting, as expected, Unable to get property 'setAttribute' of undefined or null reference. I know this is...

How to add different text after echo output using PHP

php,dom
$DOM = new DOMDocument(); @$DOM->loadHTML($html); $finder = new DomXPath($DOM); $classname = 'winning-numbers'; $nodes = $finder->query("//*[contains(@class, '$classname')]"); foreach ($nodes as $node) { echo "<p>","<b>11 AM Draw:","\n",$node->nodeValue,"</b>","</p>"; // I add paragraph and bold tags on the echo output but this site recognize the tags. } I'm almost done with it. The problem...

how can i make href to upper directory go up

html,dom,href
I have an html page in url: http://localhost:63343/x/html_pages/http_failures_table/http_failures_table_agg_bl.html with href: <a href="../http_failures_dict/http_failures_dict_bl_0.txt"> but when i click the url I'm directed to: http://localhost:63343/x/html_pages/http_failures_dict/http_failures_dict_bl_0.txt instead of http://localhost:63343/x/http_failures_dict/http_failures_dict_bl_0.txt how can i fix this?...

Java XPath returns single result instead of NodeSet

java,xml,dom,xpath
I am trying to create an XPath expression in Java (8, default XPath implementation). I am doing the following: Object res = xpath.evaluate("(//*[local-name()='PartyId'])", requestDom, XPathConstants.NODESET); I have multiple PartyId nodes in the document at the same level, because it's parent is repeating. I got my result, but only a single...

Add class to an element within an HTML Application from within VBS function

css,dom,vbscript,hta
I have an HTA that is displayed when a backup routine is complete and I'd like to be able to manipulate the HTA via VBS, showing whether or not a series of folders were backed up correctly. So, using the ID of an element within the HTA, is it possible...

PHP dom parsing

php,parsing,dom,html-parsing
I'm trying to get the values of the following table. I tried both curl/regex (I know it's not recommended) and DOM separately, but wasn't able to get the values properly. There are multiple rows in the page, so I'll need to use a foreach. I need an exact match of...

check changed value of a DOM element

javascript,jquery,dom
Is it possible to see whether an element has been changed in the DOM? In my case, I have a table with content editable and an id to access each table rows. I want to know which content has been changed. <table id="myTable"> … <td id=“name:1" contenteditable=“true"></td> <td id=“phone:1” contenteditable="true"></td>...

How to get all the tags from the tag using PHP DOM?

php,html,dom,curl
I am using PHP's curl for getting webpage data, and for extracting <a> tags from the <body> I am using DOM Document, but it is creating an error. <?php $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => "http://www.google.co.in/?gfe_rd=cr&ei=B5GBVezbDeHA8geU8pfYBw", CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => 'Webbot UA' )); $result = curl_exec($ch); curl_close($ch); if...

(CORS) How does the browser know when to do a pre-flight request

javascript,rest,dom,xmlhttprequest,cors
So I have been using CORS for a short time now, I just read up on how it works behind the scenes. My question is how does the browser know when to do a pre-flight request? There is no issue involved right now, as the browser seems to be working...

Javascript help using createElement() and appendChild()

javascript,html,dom
I'm having trouble writing some JavaScript for a project. I have the HTML code: <html> <head> <title>Mouse Tail and Spawn</title> <script src="tail.js"></script> </head> <body> <div id="tail" style="position:absolute; display:none"> Click to spawn an egg. </div> </body> </html> I want to write the JavaScript to have the text in the div to...

document.createElement multiple arguments

javascript,html,html5,dom,polymer
I was reading through the polymer documentation, and I saw this: var el2 = document.createElement('input', 'my-input'); Source Forgetting about polymer for a second, can document.createElement currently take 2 arguments? Is it related to Polymer's type-extensions? Side note: Webstorm was "complaining" when I called it with 2 arguments....

can a single MutationObserver object observe multiple targets?

javascript,html,dom,mutation-observers
I would like to use a MutationObserver object to observe changes to some of my DOM nodes. The docs give an example of creating a MutationObserver object and registering it on a target. // select the target node var target = document.querySelector('#some-id'); // create an observer instance var observer =...

Using .click() Method with Mobile Safari

javascript,jquery,css,dom,mobile-safari
I'm running into an issue using mobile Safari where jQuery's .click() method doesn't seem to fire. As far as I can tell, my code seems to be working on all other mobile browsers. Has anyone else run into this issue? It seems like this would be a common problem. I'm...

Javascript String to Nested Array

javascript,jquery,arrays,dom
I am rolling my own two-way DOM binder to link inputs to JSON as a learning opportunity without using Ember, Angular, KnockoutJS, etc. I am trying to find a way to recursively build a dynamic array based on the property name. My JavaScript definitely has a bad code smell with...

Detecting size of element before inserting it into DOM

javascript,dom,size,web-frontend
I'm writing (using pure JavaScript = no JQuery) a custom control which is a container that collapses it's contents when they span multiple lines and show only the first one. When you click a button in the control (down arrow), the container expands all of it's content. If content spans...

Changing image source in JavaScript

javascript,image,dom,onclick,imagesource
I'm new to JavaScript, and I'm trying to alternate an image every click from 1st to 2nd and from 2nd to 1st(indefinitely). I tried this: function change() { var imgId = document.getElementById("image"); var ubuntu = imgId.src="ubuntu.jpg"; var debian = imgId.src="debian.jpg" if(imgId.src="ubuntu.jpg") { return debian; } else if(debian) { return ubuntu;...

childNodes list is empty before page is loaded

javascript,jquery,google-chrome,dom
// Some jQuery to load the HTML file $(function(){ $("#myDiv").load("./someHTMLfile.html"); }); var div = document.getElementById("myDiv"); console.log(div.childNodes); console.log(div.childNodes[0]); // Prints undefined When this code runs, the list div.childNodes is empty, but when I check the variable in the Chrome console, the list is not empty. Chrome also tells me that "Object...

DOM Manipulation not executing instantly

javascript,dom,race-condition
I've experienced the issue that DOM Manipulations only take effect when the browser ran through all iterations, i.e. while, for, -loops. Example: var text = document.getElementById("text"); for (var i = 0; i < 100000000; i++) { if (i % 1000000 == 0) { setTimeout(function() { text.innerHTML += "|"; }, 0);...

Value of variable changing over time inside function w/o reassignment

javascript,dom
<script> document .getElementById('country') .addEventListener('change', function() { 'use strict'; var value1 = this.value; console.log(value1); var vis = document.querySelectorAll('.input-group-addon'), country = document.getElementsByClassName(value1); console.log(country.length); // Point One var i; if (vis !== null) { for (i = 0; i < vis.length; i++) vis[i].className = 'input-group-addon inv'; console.log(country.length); // Point Two } if (country...