> enclosed in given classes (say loremipsum and third in my example) are
> returned.
First off, I'm also new to jQuery so I apologize if my solution is the
best way to do this. Anyways, here's what I came up with
<html>
<head>
$(document).ready(function(){
$("a.lorem").click(function(){
alert($("p.lorem").eq(0).html()); // Alerts contents of first
"lorum" p tag
alert($("p.lorem").eq(1).html()); // Alerts contents of second
"lorum" p tag
return false; // Cancels link from being
followed
});
});
</head>
<body>
<a class="lorem" href="#">shoot</a>
<p class="lorem">Lorem ipsum dolor sit amet, magna massa aliquet
in
libero, a suscipit suspendisse ac penatibus, lectus donec
consequat, sed
justo
</p>
<p class="lorem"><span>Lorem ipsum dolor</span> <a href="#" >sit
amet,</a> <span>magna massa aliquet in</span>
libero, a suscipit suspendisse ac penatibus, lectus donec
consequat, sed
justo
</p>
</body>
No comments:
Post a Comment