views:

65

answers:

2

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"&gt;
</script>
+1  A: 
$(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.

XGreen
still not working with 1.4.2 . this classname `class='adobe-reader-download'` works with 1.3.2
metal-gear-solid
updated the answer
XGreen
i have just like that and it works fine with 1.4
XGreen
`$(document).ready(function(){ });' i'm already using this
metal-gear-solid
the problem must be something else.
XGreen
Xgreen - :) problem was different in link of jquery 1.4 type was `type="text/jscript"' not `type="text/javascript"` sorry for inconvenience. Should i delete this question. or i should accept any answer
metal-gear-solid
you could just accept answer. its better for me :) glad you worked it out
XGreen
+2  A: 

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 ( "}" ).

RussellUresti