Reputation: 152647
this code
var tip = "<p class='adobe-reader-download'>Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'";
tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>";
if($("div#maincontent a[href*='.pdf']").length>0){
$("div#maincontent").children(":last-child").after(tip);
works fine with this
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
type="text/javascript"></script>
but not working with this
<script
type="text/jscript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>
Upvotes: 0
Views: 177
Reputation: 6221
What do you mean by "doesn't work"? Does the tip not get appended to the page? Does the link for the tip not work? Be a bit more descriptive when you say it "doesn't work", tell us how.
I've made an example of this code here: http://jsbin.com/akugo/edit
With JSBin you can tell it what version of jQuery to use, and I've tested it using 1.3.2 and 1.4.2 and I don't see any problems. The only thing I changed from the code you posted is that I closed the "if" statement with a bracket ( "}" ).
Upvotes: 2
Reputation: 11558
$(document).ready(function() {
var tip = "<p class='adobe-reader-download'>Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'";
tip += " href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>";
if ($("div#maincontent a[href*='.pdf']").length > 0) {
$("div#maincontent").children(":last-child").after(tip);
}
});
with this:
<div id="maincontent">
<a href="sample.pdf">your pdf</a>
</div>
for outputs with jq 1.4:
Your pdf
Most computers will open PDF documents automatically, but you may need to download Adobe Reader.
Upvotes: 1