aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes JQuery Selector Help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "JQuery Selector Help needed" Watch "JQuery Selector Help needed" New topic
Author

JQuery Selector Help needed

Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hello all,

I have a HTML snippet which looks like this.

I need to form a selector which selects all the elements starting until . Can someone help me on this?

Thanks,
Srikkanth

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

You can't. There is no way to select a range of elements in that way -- at least not with a single selector. You'll either need to specify multiple selectors for each individual element, or re-arrange the HTML to suit your selection needs.

I always prefer the latter. Structure the HTML intelligently, and the selectors become easy.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Thanks for the quick response.
This HTML is generated by a third party . Probably I need to group the tags together (using java string manipulation or something). I was hoping that this could be achieved using some combination of selectors.

Thanks,
Srikkanth
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

Srikkanth Mohanasundaram wrote:I was hoping that this could be achieved using some combination of selectors.

It can. That was one of the approaches I said could work.
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Let us say i group the tags following the title paragraph (p with class name title), like this



Now, how should i form a selector to fetch the div followed by the title paragraph ? I guess something like this
$(".title + div"), but i also need to check the innerText of the title paragraph (I would want to select Title 1,Title 2 so on..).

Thanks for your help,
Srikkanth
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
documentation is helpful

http://docs.jquery.com/Selectors/contains

Eric
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Thanks for the pointer Eric.

This was the selector i was looking for . JQuery is simply awesome (Just a single line!!).Thanks for your suggestions Bear.

Thanks for your help,
Srikkanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuery Selector Help needed
 
Similar Threads
problem when integrating jspell with tinyMCE editor
Can you read this?
Displaying JSP in certain DIV tag
using CSS float attribute makes things 'leak' out of their containers ?
How to show icons in Tree using DOJO 0.4