jQuery and XPath

Discussion in 'Javascript' started by Gale, Jun 2, 2006.

  1. Gale

    Gale Guest

    I'm working on something in jQuery with XPath

    What I want to do is: if checkbox is checked, set background color od
    label that contain input(checkbox) to red

    I have this code:
    $("label[input[@checked]]").css("background", "red");

    but it doesn't working because of nested brackets [[ ]] and it freeze
    the browser
    In Xpath documentation say it can be used

    any sugestions?
    Gale, Jun 2, 2006
    #1
    1. Advertising

  2. Gale

    VK Guest

    Gale wrote:
    > I'm working on something in jQuery with XPath


    So how or anyhow is that related to JavaScript/JScript? Neither of both
    atop are connected with it.

    For JavaScript solution ask here (will be glad to help), for XPath
    solution ask at <comp.text.xml>, for jQuery plugin ask at some Eclipse
    forum.
    VK, Jun 2, 2006
    #2
    1. Advertising

  3. Gale

    Guest

    VK wrote:
    > Gale wrote:
    > > I'm working on something in jQuery with XPath

    >
    > So how or anyhow is that related to JavaScript/JScript? Neither of both
    > atop are connected with it.
    >
    > For JavaScript solution ask here (will be glad to help), for XPath
    > solution ask at <comp.text.xml>, for jQuery plugin ask at some Eclipse
    > forum.


    *OR* Before you run your mouth off about something you have no clue
    about - being in this case that the mentioned JQuery is a JAVASCRIPT
    LIBRARY supporting css / xpath / expressions to apply behaviors to dom
    elements.

    To the original poster. Drop John Resig an Email from the form on the
    jquery page. I have had similiar issues with the xpath selectors. Some
    of the custom expressions might be useful to you though.
    , Jun 3, 2006
    #3
  4. Gale

    VK Guest

    wrote:
    > *OR* Before you run your mouth off about something you have no clue
    > about - being in this case that the mentioned JQuery is a JAVASCRIPT
    > LIBRARY supporting css / xpath / expressions to apply behaviors to dom
    > elements.


    Or really? Which one of them? There are at least 3 plugin/library
    called jQuery (variant JQuery) matching the OP's description. The name
    is too "sound" for a bizword so all kind of wannabes used it for
    software of all kinds of quality. Presuming for a minite it is not
    about Eclipse but about <http://jquery.com/> (just one of numerous
    variants). In such case I'm sure OP will be glafle helped at
    <http://jquery.com/discuss/>

    If OP wanted a JavaScript help, then the traversal should go in the
    normal way, not upside down as (I presume) suggested by the "logic" of
    the library. Namely on a standard-compliant page (thus all labels have
    "for" attribute) one retrieves all labels for a given range and /then/
    accesses the attached elements:

    var labels = document.getElementsByTagName('LABEL');
    var obj = null;
    for (var i=0; i<labels.length; i++) {
    obj = document.getElementById(labels.htmlFor);
    if (obj.checked) {
    labels.style.backgroundColor = 'red';
    }
    }

    This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.
    VK, Jun 3, 2006
    #4
  5. Gale

    Gale Guest

    VK wrote:
    > wrote:
    >> *OR* Before you run your mouth off about something you have no clue
    >> about - being in this case that the mentioned JQuery is a JAVASCRIPT
    >> LIBRARY supporting css / xpath / expressions to apply behaviors to dom
    >> elements.

    >
    > Or really? Which one of them? There are at least 3 plugin/library
    > called jQuery (variant JQuery) matching the OP's description. The name
    > is too "sound" for a bizword so all kind of wannabes used it for
    > software of all kinds of quality. Presuming for a minite it is not
    > about Eclipse but about <http://jquery.com/> (just one of numerous
    > variants). In such case I'm sure OP will be glafle helped at
    > <http://jquery.com/discuss/>
    >
    > If OP wanted a JavaScript help, then the traversal should go in the
    > normal way, not upside down as (I presume) suggested by the "logic" of
    > the library. Namely on a standard-compliant page (thus all labels have
    > "for" attribute) one retrieves all labels for a given range and /then/
    > accesses the attached elements:
    >
    > var labels = document.getElementsByTagName('LABEL');
    > var obj = null;
    > for (var i=0; i<labels.length; i++) {
    > obj = document.getElementById(labels.htmlFor);
    > if (obj.checked) {
    > labels.style.backgroundColor = 'red';
    > }
    > }
    >
    > This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.
    >


    I want to do it with XPath !!!
    Gale, Jun 3, 2006
    #5
  6. Gale

    Gale Guest

    wrote:
    > VK wrote:
    >
    > To the original poster. Drop John Resig an Email from the form on the
    > jquery page. I have had similiar issues with the xpath selectors. Some
    > of the custom expressions might be useful to you though.
    >


    Thank you I will try that!
    Gale, Jun 3, 2006
    #6
  7. Gale

    VK Guest

    Gale wrote:
    > I want to do it with XPath !!!


    You cannot do it with XPath: XPath is a language to traverse nodes in
    XML document during the transformation (look for XSLT). On the
    mentioned stage JavaScript is useless as the resulting document doesn't
    exist yet. Never repeat someone bogus ads just because it sounds cool.
    You mean to say "I want to do it using pseudo-XPath syntax supported in
    the used JavaScript library". As internally these "XPath commands" is
    nothing but plain strings parsed and used by JavaScript functions, I
    presume some string parsing bug. Follow the advise of other poster -
    simply be aware that you are not using XPath - you are using XPath-like
    syntax. That makes a difference.
    VK, Jun 3, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,958
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,370
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    508
  4. Aaron Gray
    Replies:
    20
    Views:
    380
    Lasse Reichstein Nielsen
    Jul 27, 2008
  5. lorlarz
    Replies:
    6
    Views:
    209
    David Mark
    Mar 25, 2010
Loading...

Share This Page