Link to home
Start Free TrialLog in
Avatar of badwolfff
badwolfffFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do I insert a piece of html code inside an html tag using jquery?

Hi,

I have a line of HTML code as follows:
<a href="test.html" title="home">CLICK</a>

Open in new window


I would like to insert the following code before ">CLICK":
data-tip="Pause Video" href="javascript:void(0);" onclick="pauseBgVideo();"

Open in new window


so that the result is like this:
<a href="test.html" title="home" data-tip="Pause Video" href="javascript:void(0);" onclick="pauseBgVideo();">CLICK</a>

Open in new window



I am using jQuery. How do I achieve this?

thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your 'result' has two 'href's and that's an error.
Dave, the jquery attr command over writes and does not add.   Are you seeing something different?

User generated image
I was talking about the original post.
Avatar of badwolfff

ASKER

I've tried the code and it doesn't work.
I've left it on the site for the moment.
I am trying to see if I can find a workaround too.

thanks