Hi. I meant to recommend against using the same id for more than one DOM
node. I know the selector will work and that dup id's usually don't
cause any new headaches, but I've also debugged pages where someone has
used the same id more than once for different things, leading to
unexpected behavior/errors in js scripts trying to manipulate those
nodes. Just some feedback....
- Jack
Wizzud wrote:
Jack, he actually says "all links in a paragraph with id 'para'", so
using $('#para a') is perfectly correct.
On Oct 21, 8:43 pm, Jack Killpatrick <[EMAIL PROTECTED]> wrote:
I see via other replies that the .text() instead of .text issue has been
resolved, but maybe worth pointing out, too (though affecting your
issue), is that you say you're looking for multiple p's with the same
"id". Each id should only be present once on a page. Instead, use a
class and select by the class:
<p class="special">yadda</p>
<p class="special">ya</p>
$('.special a').click(function....etc)
- Jack
photoboy wrote:
I'm just starting out with jQuery and am already staring at a wall.
The goal: attach a mouse event to all links in a paragraph with id
'para' and display the text of the link.
this is what I've come up with, which obviously doesn't work:
$("#para a").click(function(){
var linkContent = $(this).text;
alert (linkContent);
});
the click event works, and an alert pops up, but the content of the
alert is a javascript function, written out in all its glory.
I can't imagine I'm too far off here. Can anyone assist?