This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

anchor tag , click and livequery

 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks ,

I have an anchor which looks like this



im trying to do something when one clicks on this anchor tag


But when i click on the anchor tag . i dont get an alert coz the control isnt going inside that livequery function

this is annoying . what am i doing wrong

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
coz is not a word UseRealWords

Your selector is saying look for an element with the tag "trigger" and find any element inside that that is the tag "a"

Your selector should just be #trigger

Eric
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric ,

#trigger doesnt work for me

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless

There is no reason it should not work if you are accurately showing your markup.

What version of jQuery are you using?
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.2.6 is the jquery version
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a unique element with an id value, that value will get selected by $('#elementId'). Are you sure that your markup is valid? That the script is being executed?
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know what exactly do you mean by

Are you sure that your markup is valid? That the script is being executed?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your HTML valid? If you have bad HTML, multiple ids of the same value, or other markup errors, nothing will work right.

Also, if the script doesn't execute, it can't do anything.
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

Im positive that the anchor tag has a unique id

lemme explain what iam trying to achieve

I have a table with th and td tags

i have an anchor tag against one of these th tags . i want to do something when the link is clicked .

By the way what would stop the script from being executed

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naveen puttu wrote:Im positive that the anchor tag has a unique id

Then there is no reason that the selector will not work.

i have an anchor tag against one of these th tags . i want to do something when the link is clicked .

Why are you using livequery for this?

By the way what would stop the script from being executed

Bad markup. Other script errors. Etc...

Are you using Firebug to help debug this?
 
Naveen puttu
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im using firebug for debugging with breakpoint

firstly , no errors reported by firebug when the page loads
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic