var obj = $("a");

for(var i = 0; i < obj.length; i++) {
obj.eq(i).wrap("<span></span>"); // wrap the hyperlink in a span tag
obj.parent().eq(i).prepend("This is text before the hyperlink");
obj.parent().eq(i).append('This is text after the hyperlink');
}

use the above common method and you can furthur change this script to look
for hyperlinks with a specific class by saying :
var obj = $("a.myclass");
or
var obj = $("a#myid");
may be even
var obj = $("h2 a");

On Thu, May 14, 2009 at 7:46 PM, vmrao <maheshpav...@gmail.com> wrote:

>
>
> Also, I would like to apply a specific CSS style to the text being
> added.
>
> Here is my CSS.
> .fileExtension {
>        padding-left:0pt;
>        font-family: Arial, Helvetica, sans-serif;
>        font-size: 7pt;
>        font-weight: normal;
>        color: #354963;
> }
>
> On May 14, 1:18 pm, vmrao <maheshpav...@gmail.com> wrote:
> > Thanks. How about if I want to make it dynamic ? Say, I have several
> > links on the page with different extensions
> > (Ex: .doc, .docx, .ppt, .pptx, .pdf, .mpg). Can I accomplish the above
> > with one statement rather than hard coding what text to append for
> > each extension ?
> >
> > On May 14, 12:23 pm, brian <bally.z...@gmail.com> wrote:
> >
> >
> >
> > > $("a[href$='.pdf']").after(' (pdf)');
> >
> > > On Thu, May 14, 2009 at 11:55 AM, vmrao <maheshpav...@gmail.com>
> wrote:
> >
> > > > I would like to display file extension along with the file links on a
> > > > web page.
> >
> > > > For example, I would like to append (pdf) next to any pdf links.
> >
> > > > The following code works to some extent but not as I intended.
> > > > $("a[href$='.pdf']").append(" (" + 'pdf' + ") ");
> >
> > > > If I use the above code, (pdf) is also underlined being part of the
> > > > link. I want (pdf) next to the link and not as part of the link.-
> Hide quoted text -
> >
> > > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -

Reply via email to