HOW CAN I ADD TEXT LINK IN A DIV USING JQUERY?

Garry Winogrand

Total Post:24

Points:168
Posted by  Garry Winogrand
JQuery 
 1297  View(s)
Ratings:
Rate this:

I want to place text 'Mindstick' with hyperlink <a href="http://www.mindstick.com" inside a div having class-id as "my-link".

How can this be done using jquery or javascript?

  1. Dag Hammarskjold

    Post:24

    Points:168
    Re: How can I add text link in a div using jquery?

    You can do this :

    $('.my-link').html('<a href="http://www.mindstick.com">Mindstick</a>');

    But it would add hyperlink to all .my-link divs, so it's better to add an ID to div and use the ID on jQuerycode.

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!