473,500 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jQuery and XPath

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?

Jun 1 '06 #1
6 11462
VK

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.

Jun 2 '06 #2

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 2 '06 #3
VK
Ab*********@gmail.com 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[i].htmlFor);
if (obj.checked) {
labels[i].style.backgroundColor = 'red';
}
}

This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.

Jun 3 '06 #4
VK wrote:
Ab*********@gmail.com 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[i].htmlFor);
if (obj.checked) {
labels[i].style.backgroundColor = 'red';
}
}

This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.


I want to do it with XPath !!!
Jun 3 '06 #5
Ab*********@gmail.com 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!
Jun 3 '06 #6
VK
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.

Jun 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3553
by: ziobudda | last post by:
Hi, I want ask you if, for a web portal/application, is better prototype or Jquery? I don't want to innesc some type of flame, but after the announce that drupal use JQuery and that the new...
1
1880
by: DuaneMoraes | last post by:
A new book on jQuery, the powerful JavaScript library, has been announced by Packt In Learning jQuery, Karl Swedberg and Jonathan Chaffer, creators of the popular jQuery learning resource...
1
49846
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
83
4108
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
20
2252
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
3099
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
2
4538
by: souporpower | last post by:
Hi All I am trying to print some HTML using JQUERY. I am posting the code. I don't see the alert. It seems as though the function is not registered when the document is loaded. Can someone...
53
8314
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
5
4901
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.