aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery Selector issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery Selector issue" Watch "jQuery Selector issue" New topic
Author

jQuery Selector issue

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Guys,

Why is the alert not showing up on click of Java Test 1 in the code sample below? Is my selector syntax not correct? I guess so...



SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Your selector is overly complicated. this will suffice:



If you want to limit it to anchor children of paragraphs:



Demo

GenRocket - A Test Data Generation Platform
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Gregg Bolinger wrote:Your selector is overly complicated. this will suffice:



If you want to limit it to anchor children of paragraphs:



Demo


Before asking for help here, I tried both of the options that you had mentioned. It seems not to show the alert. Popup blocker is deactivated on my browser. Bemused why the alert is not coming up.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Did you try the demo link I provided? Does it also not work? What browser and what version of jQuery are you using?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I'm attaching a screenshot of the page that contains this href


[Thumbnail for jQuery_href.png]

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

The demo seems to work, but why not on my machine? I use firefox 4.0. Has it got anything to do with the other jQuery functions that I have in my page?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Joe Harry wrote:The demo seems to work, but why not on my machine? I use firefox 4.0. Has it got anything to do with the other jQuery functions that I have in my page?



Try your local copy without the extra stuff (like your UI .tabs() function) and see what happens.

Use a tool like Firebug to inspect the elements after jQuery UI has gotten hold of everything and see if the markup was changed in a way that would cause the selector to stop working.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Yes, I did use Firebug to find out what gets rendered. Here it is:



Looks like the selector should work
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

The entire html body after rendering:

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Yep, seems like it should. Did you attempt it without rendering the UI tabs? Also, try adding a class to each anchor and use that as the only selector and see if it works. Get as specific as you can with your selector.




Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Gregg Bolinger wrote:Yep, seems like it should. Did you attempt it without rendering the UI tabs? Also, try adding a class to each anchor and use that as the only selector and see if it works. Get as specific as you can with your selector.






Did not work as well.

Here, again the complete html.

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

I just noticed that your binding to the click event is happening outside of jQuery's ready function. That's probably why it isn't working for you.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Spot on. Thanks for the suggestion. But can't a page have more than one ready function? I thought I have have as many as I wish on my page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Yes, a page can have as many ready handlers as you like.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

What is wrong with the following snippet?



The backAnch does not get triggered?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Are there elements with the backAnch class?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jQuery Selector issue
 
Similar Threads
layout and multibrowser hell
JQueryUI: Embedding an Accordion inside a Tab -- Problem
jQuery UI tabs not loading in the same tab
converting html to pdf
jQuery tabs UI issue