w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
XSLT to wrap all chid elements in parent tag
To start with, you should be building your XSLT on top of the XSLT identity template, which will copy all nodes in your XML for which you don't have explicit matching templates <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> Without this, XSLT's built-in templates will kick-in, and just output the text of any element it finds. The other problem with your XSLT, is that when you match a Category element, you are doing <xsl:apply-templates select="Category"/> which means you are only telling XSLT to look for any Category elements that are children of the current element. One approach you could be taking is to have your template match the parent of any Category element (excludi

Categories : Xml

Having the floating children elements determine parent width
Add position:fixed; to container .container { background: red; padding: 10px; position:fixed; Fiddle

Categories : HTML

XSL: wrap all descendant text and elements?
One way to approach that in XSLT 1.0 is through sibling recursion, as outlined in the following example: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="@* | node()" name="identity"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="speech"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()[1]"/> </xsl:copy> </xsl:template> <xsl:template match="speech/line"> <xsl:call-template name="identity"/> <xsl:apply-templates select="following-sibling::node()[1]"/> </xsl:template> <xsl:template match=

Categories : Xslt

jQuery wrap list elements containing the same text part
Try this, $("#getStyles .lv3").each(function() { txt=$(this).text().split(' ')[0]; if(!$('#result').find('.'+txt).length) { $('#result').append('<ul class="'+txt+'"><li class="lvl2">'+txt+'</li></ul>'); } $('#result').find('.'+txt).append($(this)); }); Working Fiddle

Categories : Jquery

Iterate through children of multiple set of elements (class) simultaneously
Try $('.quotes').each(function(idx){ var $quote = $(this); $quote.children().hide(); function showFirst(){ var $first = $quote.children().first().fadeIn('slow').delay(2500).fadeOut('fast', function(){ setTimeout(showFirst); $first.appendTo($quote) }) } setTimeout(showFirst, idx * 100); }) Demo: Fiddle

Categories : Jquery

How do I apply a JQuery function to elements with the same class that have a specific number of children?
Well just glancing at your code I see the if the condition is met then the class "mynewclass" will be applied to EVERY element with ul.menu_container. For you code to work you would need to formate it like this: if( $('ul.menu_container > li').length >= 3 ){ $(this).attr('class','mynewclass');} But I am fairly certain that this will not work either because it will only evaluate the first matching set. You will need to write your code using a .each() function.

Categories : Jquery

How to wrap dynamically created elements using jQuery wrap()?
Add parent() between wrap and appendTo: radio = $("<input />") .attr({ "name": "radio-" + this.uuid + "-" + i, "type": "radio" }) .wrap("<label></label>") .parent() .appendTo(someElement);

Categories : Javascript

HTML Elements whose parent elements are transparent won't go opaque
Children can't have a higher opacity than their parents as their opacities multiply. You use could png backgrounds or rgba colors: http://css-tricks.com/rgba-browser-support/ div { background-color: rgba(255,255,255,0.5); }

Categories : HTML

Add class to parent and child SVG elements
You're trying to use $.each. This will work for arrays []. According to docs, A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. For DOM elements, you need to use $("selector").each(). According to docs, Iterate over a jQuery object, executing a function for each matched element. And more : The $.each() function is not the same as $(selector).each(), which is used to iterate, exclusively, over a jQuery object. So, you have to do it this way : $("path").each( function(i) { $(this).attr("class","yourClass").parent('g').attr(

Categories : Jquery

Removing elements that have no attributes, child elements, or text during transform
This should do the job: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/> <!-- Elements/attributes to remove. Note that comments are not elements or attributes. Since there is no template to match comments they are automatically ignored. --> <xsl:template match="@*[normalize-space()='']|info|@file_line_nr|@file_name"/> <!-- Match any attribute --> <xsl:template match="@*"> <xsl:copy> <xsl:apply-templates select="@*"/> </xsl:copy> </xsl:template> <!-- Match any element --> &l

Categories : Xml

Comparing class member array elements and main elements
Your canswers member is not a valid declaration. It is likely using an extension provided by your compiler to support the C flexible array member. This will act like a 0 sized array, and your access to the canswers variable are thus reading and writing beyond the object boundary, resultig in undefined behavior. You should either declare canswers with the right array size, or allow it to be a vector<char> or array<char, 20> instead. For vector<char>: class TestGrade { public: void setKey(char []); void grade(char []); std::vector<char> canswers; void display(); }; If you use vector<char>, you would need to change how you implement setKey(). void TestGrade::setKey(char answers[]) //setting values from "key" array in main { canswers.clear

Categories : C++

Check all tr elements for visibility:hidden between two same class tr elements
Try this - $('tr.header').each(function(){ if ($(this).nextUntil("tr.header").filter(function(){ return $(this).is(':visible'); }).length == 0){ $(this).hide(); } else { $(this).show() } });

Categories : Jquery

Extracting the text from the child elements of a div with a class?
The a elements in those sections would be: data.css('.nbaBreakingNewscv a') That means any a element that descends from an element with class nbaBreakingNewscv. To show the text of those a elements you would do: data.css('.nbaBreakingNewscv a').each do |a| puts a.text end

Categories : Ruby

Get id and text from all elements with class and put into JSON array
For each selected_pages you need to create a page object as shown below var publish = []; $('.selected_pages').each(function () { var pages = new Object(); pages.name = $(this).text(); pages.id = this.id; publish.push({ Pages: pages }); }); var json_pages = JSON.stringify(publish); alert(json_pages) I would recommend using .map() here var pages = $('.selected_pages').map(function () { var page = new Object(); page.name = $(this).text(); page.id = this.id; return { Pages: page}; }).get(); var json_pages = JSON.stringify(publish); console.log(json_pages) Demo: Fiddle

Categories : Jquery

Wrap elements in a
  • You can use the wrap function: $(function() { $('#data-table_paginate a').wrap('li'); }); This will find all anchors in the data-table_paginate div and wrap them in an li element.

    Categories : Jquery

    DIV Wrap two different elements inside a DIV by JS
    You can use wrapAll() <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> jQuery(function() { $('img, .small-message', '#container').wrapAll('<div id="wrap-inside" />'); }); </script> FIDDLE

    Categories : Jquery

    Wrap pairs of elements?
    Like this? $('.parent > div:odd').each(function(i){ $(this) .prev() .addBack() .wrapAll($('<div/>',{'class': 'new-' + (i+1)})); }); Demo Get the odd ones selected i.e 1, 3, 5 etc based on index(0 based); Iterate the odd ones get the prev element relative to the odd(which needs to be paired), use andSelf addBack to select that too and then use wrapAll on the pair. if you want to ignore first x of them then do this: $('.parent > div:gt(' + (x-1) + '):odd').each(function(i){ $(this) .prev() .addBack() .wrapAll($('<div/>',{'class': 'new-' + (i+1)})); }) Demo

    Categories : Javascript

    How to wrap elements in a and then append the td to tr
    Try var map = $('#col').replaceWith(function(){ var map = $(this).contents().map(function(idx){ var $td = $('<td />'); if(this.nodeType == 3){ if($.trim($(this).text()) == ''){ return } else { $td.addClass('text-class'); } } else if($(this).is('p')){ $td.addClass('p-class'); } return $td.append(this) }); map.get(0).attr('id', this.id) return map.get() }); Demo: Fiddle

    Categories : Jquery

    Wrap elements with jQuery
    The problem is you are only adding the anchor elements, you are not including the content that you wrapped. function successFn(data) { var keyWord = $("#input").val(); // convert string html to object var wrapper = $('<div/>').html(data); var anchors = wrapper.contents(); // add data-keyword to all results anchors.each( function (i) { $(this).attr('data-keyword', keyWord); $(this).wrap('<div class="xXx"></div>'); }); // print results $("#results").empty().append(wrapper.contents()); }

    Categories : Javascript

    Don’t wrap span elements
    Just set the width of .cards to some huge number: .cards { position: relative; top: 10px; width: 99999%; } jsFiddle The default width of .cards is constrained to the width of its parent .board, 400px. Most of the time, having a maximum width is good, because it causes children to wrap if necessary. But since you don’t mind overflow, it’s okay to override this.

    Categories : CSS

    rails creating default child when parent doesn't have children and not showing it when parent has children
    after_create should work just fine, assuming you associated any children before saving the parent: class ParentModel < ActiveRecord::Base has_many :child_models after_create :ensure_child_exists def ensure_child_exists child_models.create(default: true) unless child_models.exists? end end If you then need to remove this child if new ones are added at some later point, you'll need to have a 'default' flag on the child to identify for removal, then add a callback to trigger the default child removal. class ChildModel < ActiveRecord::Base attr_accessible :default belongs_to :parent after_create :remove_default_if_unneeded scope :default, -> { where(default: true) } def remove_default_if_unneeded parent.child_models.default.destroy_all unless self.defa

    Categories : Ruby On Rails

    Wrap elements depending on their siblings
    You HTML is invalid first of all because if you look here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul Permitted content for ul - zero or more <li> elements, eventually mixed with <ol> and <ul> elements. But you can wrap all your elements by using prevAll() to get all previous siblings and .nextAll() to get all siblings after the element - then .wrapAll() will wrap them all with a single element $('.image') // start at .image .prevAll('p') // <-- get all p's before .image .wrapAll('<div class="new" />') // wrap all in a div .end() // go back to .image .nextAll('p') // get all p's after .image .wrapAll('<div class="new" />') // wrap all in div .end() // go back to .image .wrap('

    Categories : Javascript

    jQuery wrap and re-order elements inside
    This should work: $('a.top_link+div.sub').each(function () { $(this).insertBefore($(this).prev()).add($(this).next()).wrapAll('<li class="aaa">'); }); For each div.sub, the above code does: Move it to before the <a> Add the <a> to the collection Wrap both in an <li> Demo: http://jsfiddle.net/vjC3x/

    Categories : Jquery

    get children of all previous elements with jquery
    You need to use .find to get the span since it isn't a child of the li (it's a descendant). $(this).closest('li.radio').prevAll().find('span').addClass('selected'); you should chain it off of addClass: $(this).addClass('selected').closest('li.radio').prevAll().find('span').addClass('selected');

    Categories : Jquery

    how can I check when the mouse is out of any of the children elements?
    I personally take the lazy way out and use jQuery's hover method to set them both at once rather than use mousein and mouseout separately. This lets jQuery deal with children in and out, something like: jQuery("li").hover(function() { //mousein actions }, function() { //mouseout actions } );

    Categories : Javascript

    Android | Get all children elements of a ViewGroup
    (source) If you want to get all the child views, as well as the views within children ViewGroups, you must do it recursively, since there is no provision in the API to do this out of the box. private ArrayList<View> getAllChildren(View v) { if (!(v instanceof ViewGroup)) { ArrayList<View> viewArrayList = new ArrayList<View>(); viewArrayList.add(v); return viewArrayList; } ArrayList<View> result = new ArrayList<View>(); ViewGroup viewGroup = (ViewGroup) v; for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); ArrayList<View> viewArrayList = new ArrayList<View>(); viewArrayList.add(v); viewArrayList.addAll(getAllChildren(child))

    Categories : Android

    Display list elements in separate inputs
    Your approach is good but you mistyped the value of the input. Replace this: <input type="text" value="${pn}" /> with this: <input type="text" value="${p}" />

    Categories : Jsp

    Detecting if inputs match by having common elements
    The below would work for you. function vali() { var add1Str = document.getElementById('persAdd1').value; var add2Str = document.getElementById('addLine1').value; var arr1 = add1Str.split(" "); var arr2 = add2Str.split(" "); var arr3 = []; for (var i = 0; i < arr1.length; i++) { for (var j = 0; j < arr2.length; j++) { if (arr1[i] === arr2[j]) { arr3.push(arr1[i]); //console.log(arr3); } } } if (arr3.length > 0) { //check if the array 3 has any items, if yes alert error. alert("error"); } } Demo

    Categories : Javascript

    Why does BeautifulSoup .children contain nameless elements as well as the expected tag(s)
    The elements of .children can be NavigableStrings as well as Tags. In the case of your example, they're the whitespace before and after the td element. This variation on your code hopefully makes it clear: >>> rows = soup.findAll('tr') >>> for r in rows: ... print("row:", r.name) ... for c in r.children: ... print("---") ... print(type(c)) ... print(repr(c)) ... row: tr --- <class 'bs4.element.NavigableString'> ' ' --- <class 'bs4.element.Tag'> <td> <div> <b> Icon </b> </div> </td> --- <class 'bs4.element.NavigableString'> ' '

    Categories : Python

    How to get children elements from a Page that's embedded in a FlipView?
    Set the name of text block you like to change then use this function to get instance of them: FrameworkElement.FindName http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.findname(v=win.10).aspx Other way, user MVVM pattern to display data on UI.

    Categories : C#

    How can I get a handle on ng-repeat children elements in my custom directive?
    To achieve reordering, you have several options: Manipulate DOM. IMHO, this is the least preferred way, it's not very angular. Re-order the array ([1, 2, 3]) which is used in ngRepeat in your linking function. Use orderBy filter (doc) I've created a plunk to demonstrate 2 and 3, hope it can help. http://plnkr.co/edit/vrgeBoJZiG6WMu4Rk46u?p=preview

    Categories : Javascript

    Children of Floated Elements Not Re-Positioning in Chrome/Safari
    The fix from this answer fixes it for me: .float { -webkit-transform: scale3d(1,1,1); } http://jsfiddle.net/thirtydot/GYFqU/3/ Similarly to what I said in that answer, this also appears to be a WebKit rendering bug. I also said "I'm not sure if there are any downsides to this fix", and the same thing still applies, but that answer is now over a year old with +20/-0 votes and no negative comments, so I guess it's fine.

    Categories : Javascript

    Is it possible to make elements in foundation not wrap around automatically when window width is too small?
    What you can do is write higher specificity rules which will over ride less specific rules so for example, you can assign a custom class to the container elements like <div class="row custom_wrapper"> <div class="large-9 columns custom_inner_wrapper"> <div class="my-element">Some elements1</div> <div class="my-element">Some elements2</div> <div class="my-element">Some elements3</div> </div> </div> Now you can target these elements like this... .custom_wrapper { /* Target .custom_wrapper */ } .custom_inner_wrapper { /* Target .custom_inner_wrapper */ } Now use this to target the child elements like .custom_wrapper .custom_inner_wrapper div:nth-of-type(1) { /* Targets 1st div inside .custom_inn

    Categories : CSS

    Use the :hover selector to alter the rules of deep children elements with pure CSS
    you need to remove the >'s <div id='a'> <div id='b'></div> <div id='c'> <div id='d'></div> </div> </div> #a:hover #c #d { opacity: 0 !important; } http://jsfiddle.net/qDRwa/ This is an example of it with different id names.

    Categories : CSS

    select parent node if all children have assigned class
    Something like this? $("ul li").filter(function () { var all = $(this).find('> ul > li'); //get all immediate ul and its immediate li's var selected = $(this).find('> ul > li.selected'); //get all immediate ul and its immediate li's with class selected return all.length && all.length == selected.length; //return if there are li's and all are selected }).addClass('selected'); //add class Demo

    Categories : Jquery

    php inheritance: children classes to inherit the data in the parent class?
    It seems you're mixing up the template (the class) and the objects (instances of a class) somehow. How would instanciating one object of class base with some given initial values have any impact on other objects of class child? Instances of class child WILL NOT dynamically "inherit" some property of an instance of class base. If you want to initialize some protected properties from your base class __construct method, and if you want that to be possible also from your child class without having to re-write the __construct method, then you must NOT overwrite the __construct method of your child class.

    Categories : PHP

    find ul if it's parent elements is li
    Get all ul's then filter only those items whose parent is a li $('ul').filter(function(){ return $(this).parent().is('li') }).addClass('dropdown-menu') for second case in comment add dropdown class to the li if it has ul elements as child $('li:has(ul)').addClass('dropdown')

    Categories : Javascript

    CSS hide elements when they aren't in the parent
    This will not work the way you want. Usually, to make sure a child element is contained visually by the parent, you need to set overflow:hidden; to the parent element. In your case you use height:0; width:0; for your parent and you just have borders to depict your element... no dice with that one AFAIK, cause setting overflow to hidden on an 0x0 px parent - will not make visible your child elements.

    Categories : Jquery

    how do i vertically center two elements in a parent?
    Make a small change to your HTML. <footer> <button class="btn-primary">Reply</button> </footer> <footer> <em>&nbsp;</em> <button class="btn-primary">Reply</button> </footer> Add some text to your <em> it works as expected. (If you don't want any text in there, just put &nbsp; for a space.) Fiddle here.

    Categories : CSS

    Jquery targeting elements within parent div
    Those interior images are not the siblings of the swatches div, they are its children. You also need to add 'selected' to the right child $('.swatches').click(function(event) { var clicked = event.target; $(this).children().children().removeClass('selected'); $(clicked).addClass('selected'); }); This should work, but IMO a better solution is to have a 'select' div with an overlay image (like a selector box) and transparency, then just move that div's position to the right color on click, instead of assigning and removing classes

    Categories : Jquery



    © Copyright 2017 w3hello.com Publishing Limited. All rights reserved.