[jQuery] whats wrong with this selector ?
Hi All,
In the following code, I expect the document to pop a message box
saying 'para1' upon load. However it doesn't seem to work. I am trying
to select a 'p' element that has a link in it. What do u think is
wrong ?
--
<html>
<head>
<script type="text/javascript" src="starterkit/jquery-1.2.6.js"></
script>
<script type="text/javascript">
$(document).ready(function() {
$("p[a]").each(function() {
alert(this.id)
});
});
</script>
</head>
<body>
<p id='para1' class='haha'>
<a id='para1_a1' href="http://jquery.com/">jQuery</a>
<p id='para2'>
<span>This is a span in para2</span>
</body>
</html>
---
$("p[a]") should select all paragraphs that have a link in them, which
is true for para1
(I got this selector from: http://docs.jquery.com/DOM/Traversing/Selectors#Using_CSS_and_XPath_Together)
thanks,
regards,
Puneet