javascript - Select / Clone parent of child class - append text to various attributes within parent and appendTo / insertAfter result -


I'm trying to, as the title says, select a basic div by providing a child's class.

Then I need to take all the contents of this parent and

  1. Add text to the beginning of the "id" attribute of all elements
  2. Add the text to the beginning All the elements for the "for" attribute of

    and then I need to output it either by insertAfter or any other device I attach it to an empty device I would like to have a class or an ID.

    So far, I have found a bit of a mess:

      $ ('A [class = "maincatlink]]) // To select parent It is used for .parent () / parent class = "div2", but we can not use "div2" as the selector .clone ($ () Attr ('for', + 'helloworld')). ( $ ("Input") address ('id', + 'helloworld')) .inertAfter (". LeftBoxContainer");});   

    Here are some problems, first of all To apply this ID and not to change the cloned material, the original material is also being cloned. The second thing I do not understand is how to add "helloworld" to the beginning of the id or the result. The result is ending here id = "nan" - OK, the code is just wrong, if someone gives you some hints Thanks so much.

    More simple explanation without dipping into my ugly code:

    I have parents at $ ('a [class = "maincatlink"]) You must select - Add static text for the beginning of all input ids, at the beginning of all Add static text to label and output in a div elsewhere on the page.

    Editing: // More information on HTML

      & lt; Div class = "div2" & gt; ;; & Lt; / Labels & gt; & Lt; A href = "checkbox 1"; & Lt; Input check = "" class = "catchalk box" id = "checkbox adi" type = "checkbox" & gt; Label class = "main codeal" "http://support.microsoft.com/index.php?main_page=index&cPath=1" class = "on maincotlin" & gt; Mobile phone & lt; / A & gt; & Lt; Div class = "div1" & gt; & Lt; Div class = "div2" & gt; & Lt; Input check = "" class = "catcheckbox" id = "checkboxid2" type = "checkbox" & gt; & Lt; Label class = "subcatlabel" = "checkboxid2" & gt; ; / Labels & gt; & Lt; A href = "javascript: zero (0)" style = "cursor: default" square = "on sub-cell" & gt; Epley & lt; / A & gt; & Lt; / Div & gt; & Lt; / Label & gt; For & lt; Div class = "div2" & gt; Input class = "catcheckbox" id = "checkboxid6" type = "checkbox" & gt; Label class = "subcatlabel" = "checkboxid6" & gt; & Lt; A href = "http://127.0.0.1/zen11/index.php?main_page=index&cpath=1_6" class = "off sub link" & gt; Samsung & lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

    As the HTML given above, when a category or sub-class is active, it uses the class "on the main portal" and "sub-subclass". If the class is not active (the user is browsing) the class "Off Main Static / Subcategory" is implemented.

    The "current" class resonates in all previous categories, which is part of the currently selected sub-category. I want to select all these "on" categories and list them in another div.

    JS:

      $ (function () {var clone = $ ('.on.maincatlabel'). Parent () .clone (); cloned.find ( 'Label') .ech (function (element) {$ (element) .attr ({'id': 'prefix-' + $ (element) .attr ('id'), 'for': 'prefix- '$ (Element) .attr (' for ')})}}; cloned.appendTo (' body '); $ (document) .on (' click ',' label.on ', function (e) {window Location.href = $ (this) .attr ('data-href');});});   

    Appearing as HTML:

      & lt; div c Lass = "div2" & gt; label class = "maincatlabel on" for = "checkboxid1" data- href = "http://127.0.0.1/zen11/index.php?main_page=index&cpath= 1 "& gt; & lt; input checked =" "class =" catcheckbox "id =" checkboxid1 "type =" checkbox "/> mobile phone  gt; div class =" div1 " "& Gt; & lt; Div class = "div2" & gt; & Lt; Label class = "subcatlabel on" for = "checkboxid2" & gt; & Lt; Input check = "" class = "catchoxbox" id = "checkbox ad2" type = "checkbox" /> Epley & lt; / Labels & gt; & Lt; / Div & gt; & Lt; Div class = "div2" & gt; & Lt; Label class = "off subcatlabel" = "checkboxid6" data-href = "http://127.0.0.1/zen11/index.php?main_page=index&cPath=1_6" & gt; & Lt; Input class = "catcheckbox" id = "checkboxid6" type = "checkbox" /> Samsung & lt; / Label & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;   



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -